C:\Python27\python.exe E:/work/pythonPrj/test.py utf-8 Traceback (most recent call last): File "E:/work/pythonPrj/test.py", line 13, in <module> print r.text UnicodeEncodeError: 'gbk' codec can't encode character u'\xee' in position 22346: illegal multibyte sequence
在此插入代码
from future import unicode_literals
author = 'wmeng'
import requests from bs4 import BeautifulSoup
r = requests.get('http://movie.douban.com/top250?start=0&filter=&type="') print r.encoding
print r.text
豆瓣本身是utf-8编码,你用gbk解码自然报错
Sign in to make a reply
枯木残师
C:\Python27\python.exe E:/work/pythonPrj/test.py utf-8 Traceback (most recent call last): File "E:/work/pythonPrj/test.py", line 13, in <module> print r.text UnicodeEncodeError: 'gbk' codec can't encode character u'\xee' in position 22346: illegal multibyte sequence
from future import unicode_literals
!/usr/bin/python
--coding:utf-8--
author = 'wmeng'
import requests from bs4 import BeautifulSoup
r = requests.get('http://movie.douban.com/top250?start=0&filter=&type="') print r.encoding
print r.text