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)时,它可以正常工作。但当我在学校机器上使用Python 3.4时,它会显示错误信息。我该如何解决这个问题?
self.msg = base64.b64decode(self.xml.encode('utf-8'))
返回了File "/opt/python3/current/lib/python3.4/base64.py", line 90, in b64decode return binascii.a2b_base64(s) binascii.Error: Incorrect padding
。 - BadEggX