python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报错UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128),python没办法处理非ascii编码的,此时需要自己设置python的默认编码,一般设置为utf8的编码格式。

在程序中加入以下代码:即可将编码设置为utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

相关文章:

  • 2021-10-22
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案