代码是:
3.py
# -*- coding=utf-8 -*-
from pyquery import PyQuery as pq
import codecs
d = pq(url='http://www.baidu.com/')
sep = d('body').html().decode('gb18030').encode('utf-8')
file = codecs.open('new.html', 'w', 'utf-8')
file.write(se)
file.close()
python 111.py出错信息如下:
Traceback (most recent call last):
File "3.py", line 6, in <module>
sep = d('body').html().decode('gb18030').encode('utf-8')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 146-149: ordinal not in range(128)
3.py
# -*- coding=utf-8 -*-
from pyquery import PyQuery as pq
import codecs
d = pq(url='http://www.baidu.com/')
sep = d('body').html().decode('gb18030').encode('utf-8')
file = codecs.open('new.html', 'w', 'utf-8')
file.write(se)
file.close()
python 111.py出错信息如下:
Traceback (most recent call last):
File "3.py", line 6, in <module>
sep = d('body').html().decode('gb18030').encode('utf-8')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 146-149: ordinal not in range(128)
