mac os系统10.10.5 pycharm4.5.4 UnicodeDecodeError(python3)
阿神
阿神 2017-04-18 09:39:35
0
0
695

只有这么一点点,怎么都想不通报错在哪里

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...

阿神
阿神

闭关修行中......

membalas semua(0)
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan