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()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM