![](/img/trans.png)
[英]Pipreqs: UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1206: character maps to <undefined>
[英]UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 7736: character maps to <undefined>
UnicodeDecodeError:“charmap”編解碼器無法解碼 position 7736 中的字節 0x98:字符映射到<undefined>
def ReadAllText(path):
r = open(path.replace("\\x", "%"))
text = r.read()
r.close()
return text
有人可以幫我嗎?
我遇到了類似的問題(百萬記錄 txt 文件),並嘗試了以下基於互聯網解決方案的方法,但它不起作用,
工作解決方案:
它不能解決問題,但解決方法是將文本文件保存為 ANSI 編碼並再次運行腳本。
另一個想法是像這樣打開文件:
open(file, errors='ignore')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.