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

Python大约 279 字

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')
阅读 618 · 发布于 2019-04-18

————        END        ————

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

昵称:
随便看看换一批