【发布时间】:2015-12-27 00:01:01
【问题描述】:
我正在制作一个 Python 程序,用于在网页中搜索单词。虽然,当我尝试
website = urllib.request.urlopen(url)
content = website.read()
website.close()
test = html2text.html2text(content)
print(test)
我收到此错误:
test = html2text.html2text(content)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site- packages/html2text/__init__.py", line 840, in html2text
return h.handle(html)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site- packages/html2text/__init__.py", line 129, in handle
self.feed(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/html2text/__init__.py", line 125, in feed
data = data.replace("</' + 'script>", "</ignore>")
TypeError: a bytes-like object is required, not 'str'
我是 Python 新手,所以我不确定如何处理此错误。
Python 3.5,Mac。
【问题讨论】:
标签: python python-3.x urllib