TypeError: 'str' does not support the buffer interface

后端 未结 7 934
南方客
南方客 2020-11-22 03:11
plaintext = input(\"Please enter the text you want to compress\")
filename = input(\"Please enter the desired filename\")
         


        
7条回答
  •  不知归路
    2020-11-22 03:47

    You can not serialize a Python 3 'string' to bytes without explict conversion to some encoding.

    outfile.write(plaintext.encode('utf-8'))
    

    is possibly what you want. Also this works for both python 2.x and 3.x.

提交回复
热议问题