原文:Python读取txt文件报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 0

Python使用open读取txt中文内容的文件时,有可能会报错,报错内容如下:UnicodeDecodeError: utf codec can t decode byte xc in position 。 这里举一个例子:txt open threekingdoms.txt , r ,encoding utf .read ,在运行时就会报错。 要处理这个问题有两个办法,如下: 第一个办法,将 ...

2020-04-01 15:59 0 6486 推荐指数:

查看详情

 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM