mac os系统10.10.5 pycharm4.5.4 UnicodeDecodeError(python3)
只有这么一点点,怎么都想不通报错在哪里
from bs4 import BeautifulSoup
with open("/Users/songfei/learning/python/1_2answer_of_homework/1_2_homework_required/index.html","r") as html_data:
#print(html_data.read())
print("----------------")
soup = BeautifulSoup(html_data,"lxml",from_encoding="utf-8")
print(soup)
报错:
Traceback (most recent call last):
File "/Users/songfei/learning/python/test/homework2.py", line 7, in <module>
soup = BeautifulSoup(html_data,"lxml",from_encoding="utf-8")
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/__init__.py", line 191, in __init__
markup = markup.read()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 16338: ordinal not in range(128)
关键是我们mac的命令行运行是正常的,求教
html源码,求大神帮看,是我的pycharm打开方式不对,,还是咋地
http://7xt0j5.com2.z0.glb.qin...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论