Python UnicodeDecodeError: 'gbk' codec can't decode byte 0x80

Python About 279 words

Python读取文件保存

Traceback (most recent call last):
  File "D:/test.py", line 2, in <module>
    line = f.readline()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 2093: illegal multibyte sequence

解决办法

指定编码为UTF-8

file = open('log.log','r', encoding='UTF-8')
Views: 4,661 · Posted: 2019-04-18

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh