当我在运行一个基于scrapy的爬虫时出现UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 12: ordinal not in range(128)的报错,原因是原因就是python的str默认是ascii编码,和unicode编码冲突。

  解决办法:在代码中加入

import sys

reload(sys)

sys.setdefaultencoding('utf8')

就可以解决。

相关文章:

  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-10
  • 2021-06-06
  • 2021-07-24
  • 2021-08-01
  • 2021-07-24
相关资源
相似解决方案