'ascii'编解码器不能对位置0中的字符u'\ xd7'进行编码:序数不在范围内(128)

时间:2017-06-07 16:06:39

标签: python

import urllib2
import html2text

print 'Please input URL with the text you want to analyze: '
url = raw_input()
page = urllib2.urlopen(url)
html_content = page.read()
print html_content
rendered_content = html2text.html2text(html_content)
f = open('file_text.txt', 'w')
f.write(rendered_content)
f.close()

试图将文件保存到我的电脑。我知道ASCII

有问题

1 个答案:

答案 0 :(得分:0)

改变
html_content = page.read()

html_content = page.read().decode(errors='replace')

str.decode