UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2

读取文件时遇到

Traceback (most recent call last):
File "fenci.py", line 21, in <module>
text = open(path.join(d, 'job1000.txt')).read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 73: illegal multibyte sequence

text = open(path.join(d, 'job1000.txt')).read()

改为

text = open(path.join(d, 'job1000.txt'),'rb').read()

 

posted @ 2020-06-01 16:17  慕尘  阅读(3510)  评论(0编辑  收藏  举报