今天在爬网页的时候碰到了UnicodeEncodeError错误:

UnicodeEncodeError: 'ascii' codec can't encode characters in position

通过自己Google后,发现Python默认是ascii编码,识别有些中文字符时就会报错。

解决方法很简单,3句话。

import sys
reload(sys)

sys.setdefaultencoding('gbk')

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
猜你喜欢
  • 2021-06-22
  • 2021-11-06
  • 2021-10-28
  • 2022-02-08
  • 2022-12-23
相关资源
相似解决方案