嗨... 我想带一个像''supercalifragilisticexpialidocius'' 这样的字符串并将其写成二进制形式的文件 - - 这样一来,如果用户试图打开ascii文本 编辑器,那么用户就无法读取字符串。我还希望能够将二进制形成的数据读回 到字符串格式,以便它显示原始值。在Python中有没有 方法呢? 谢谢! Harlin
解决方案Harlin Seritt写道: 嗨... 我想带一个字符串''supercalifragilisticexpialidocius'' 并将其写成二进制形式的文件 - 这样用户无法阅读 字符串以防他们尝试打开ascii文本 编辑器。我还希望能够将二进制形成的数据读回 到字符串格式,以便它显示原始值。在Python中有没有 方法呢? 谢谢! Harlin
尝试在wb模式下打开文件。 Colin W.
Harlin Seritt写道: 嗨... 我想采取像''这样的字符串supercalifragilisticexpialidocius'' 并将其写入二进制形式的文件 - 这样一来,如果用户试图打开ascii文本之类的东西,用户就无法读取字符串 编辑。我还希望能够将二进制形成的数据读回 到字符串格式,以便它显示原始值。在Python中有没有 方法呢? 谢谢! Harlin
尝试在wb模式下打开文件。 Colin W.
2月21日下午7:02,Colin J. Williams < c ... @ sympatico.cawrote: Harlin Seritt写道: 嗨.. 。我想带一个字符串''supercalifragilisticexpialidocius'' 并将其写入二进制文件表单 - 这样用户无法读取字符串,以防他们尝试打开ascii文本 编辑器。我还希望能够将二进制形成的数据读回 到字符串格式,以便它显示原始值。在Python中有没有 的方法呢?
谢谢!
Harlin
尝试在wb模式下打开文件。 Colin W.
感谢您的帮助。 我尝试过这样做: text =''supercalifragilisticexpialidocius'' open(''sambleb.conf'',''wb'') .write(text) 之后,我能够用文本 编辑器成功打开文件,它显示: ''supercalifragilisticexpialidocius'' 我希望它能让它出现一些奇怪的不可读文本。然后 当然能够将它转换回字符串。这是偶数吗?可能吗? 谢谢, Harlin
Hi... I would like to take a string like ''supercalifragilisticexpialidocius'' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I''d also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks! Harlin
解决方案 Harlin Seritt wrote: Hi... I would like to take a string like ''supercalifragilisticexpialidocius'' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I''d also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks! HarlinTry opening your file in the ''wb'' mode. Colin W.
Harlin Seritt wrote: Hi... I would like to take a string like ''supercalifragilisticexpialidocius'' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I''d also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks! HarlinTry opening your file in the ''wb'' mode. Colin W.
On Feb 21, 7:02 pm, "Colin J. Williams" <c...@sympatico.cawrote: Harlin Seritt wrote: Hi...I would like to take a string like ''supercalifragilisticexpialidocius'' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I''d also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python?
Thanks!
Harlin
Try opening your file in the ''wb'' mode. Colin W.
Thanks for the help. I tried doing this: text = ''supercalifragilisticexpialidocius'' open(''sambleb.conf'', ''wb'').write(text) Afterwards, I was able to successfully open the file with a text editor and it showed: ''supercalifragilisticexpialidocius'' I am hoping to have it show up some weird un-readable text. And then of course be able to convert it right back to a string. Is this even possible? Thanks, Harlin
更多推荐
转换为二进制并转换回字符串
发布评论