[爬虫]Scrapy 错误ordinal not in range(128)

报错了:

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xb0 in position 1: ordinal not in range(128)

运行错误信息.png

应该是出了编码问题

在python的Lib\site-packages文件夹下新建一个sitecustomize.py:

import sys  
sys.setdefaultencoding('gb2312')

再次运行,OK,问题解决了,看一下结果:

运行正确信息.png

  • 或者在代码中加入下面几行代码
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )

猜你喜欢

转载自blog.csdn.net/xc_zhou/article/details/80604015