当前位置:   article > 正文

gbk‘ codec can‘t decode byte 0xac in position 411: illegal multibyte sequence_gbk' codec can't decode byte 0xac in position 4: i

gbk' codec can't decode byte 0xac in position 4: illegal multibyte sequence

读取txt时报错:

gbk' codec can't decode byte 0xac in position 411: illegal multibyte sequence
  • 1

错误的意思是:Unicode的解码(Decode)出现错误(Error)了,以gbk编码的方式去解码(该字符串变成Unicode),但是此处通过gbk的方式,却无法解码(can’t decode )。“illegal multibyte sequence”意思是非法的多字节序列,即没法(解码)了。

在读取时加入utf-8即可

    with open("C:/V0.0.2/res_10w.txt", "r", encoding="utf-8") as fz:
        results = fz.readlines()
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/151064
推荐阅读
相关标签
  

闽ICP备14008679号