写爬虫的时候出现:'latin-1' codec can't encode characters in position 9-13: ordinal not in range(256)

写爬虫的时候出现:UnicodeEncodeError: 'latin-1' codec can't encode characters in position 9-13: ordinal not in range(256);原因是:设置  headers = {'user-agent': 'xxoo’}的时候用了window环境下浏览器的 user-agent,但是我是在乌班图中运行程序,所以报错,因此,把user-agent换为乌班图环境中浏览器的user-agent即可。

你可能感兴趣的:(写爬虫的时候出现:'latin-1' codec can't encode characters in position 9-13: ordinal not in range(256))