首页 > 代码库 > python TypeError: must be str, not bytes错误

python TypeError: must be str, not bytes错误

1 TypeError: must be str, not bytes错误:
2 
3 解答: 
4  写文件处 f=open(filename, w)应该写为 open(filename, wb)
5  读文件时 f=open(filename,rb)
UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x80 in position 0: illegal multibyte sequence解决方法同上

 

python TypeError: must be str, not bytes错误