出现 ascii' codec can't decode byte 0xe5 in position : ordinal not in range(128) 的错误

 

这是因为系统的默认编码assic,

因此要先设置系统默认编码为UTF-8,使用sys.setdefaultencoding('utf-8')
但同时这个命令会因为别的地方使用了

因此要先设置系统默认编码为UTF-8,使用sys.setdefaultencoding('utf-8')


但同时sys.setdefaultencoding方法在python导入site.py后就删除了,因此要使用 reload(sys)才行


总的方法是

 

reload(sys)
sys.setdefaultencoding('utf-8')
res=unicode(res)

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-06-22
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2021-11-06
  • 2021-06-18
  • 2022-12-23
  • 2021-04-19
  • 2021-08-22
相关资源
相似解决方案