UnicodeDecodeError: 'gbk' codec can't decode byte 0x9a in position 8: illegal multibyte sequence

版权声明:转自可爱的安安的博客!qq:1085589289 https://blog.csdn.net/ac1085589289/article/details/85306457
with open('b1.s') as file_object:
	contents=file_object.read()
	print(contents)

报错:
在这里插入图片描述原因:
读取文件中有中文
解决办法:
打开文件时以utf-8格式打开。

with open('b1.s',encoding='utf-8') as file_object:
	contents=file_object.read()
	print(contents)

总结:我是天才

猜你喜欢

转载自blog.csdn.net/ac1085589289/article/details/85306457