【发布时间】:2015-01-25 10:36:43
【问题描述】:
im = Image.open(filePath) # load image
self.msg = str(bytearray(list(im.getdata()))) # convert image data to string
encodedMsg = base64.b64encode(self.msg)
当我尝试将从图像读取的数据编码为 base64 时,它返回错误:
File "Steganography.py", line 42, in msgToXml
encodedMsg = base64.b64encode(self.msg)
File "/opt/python3/current/lib/python3.4/base64.py", line 62, in b64encode
encoded = binascii.b2a_base64(s)[:-1]
TypeError: 'str' does not support the buffer interface
当我在家使用 Ubuntu (python 2.7) 时它可以工作。但是当我使用学校机器(python3.4)时它显示错误。我该如何解决这个问题?
【问题讨论】: