iamYvette
2017-06-11 16:30
代码:
from urllib.request import urlopen from urllib.request import Request from urllib import parse req = Request("http://www.thsrc.com.tw/tw/TimeTable/SearchResult") postData = parse.urlencode([ ("StartStatio","2f940836-cedc-41ef-8e28-c2336ac8fe68"), ("EndStation","977abb69-413a-4ccf-a109-0272c24fd490"), ("SearchDate","2017/06/11"), ("SearchTime","13:00"), ("SearchWay","DepartureInMandarin") ]) req.add_header("Origin","http://www.thsrc.com.tw") req.add_header("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36") resp = urlopen(req, data=postData.encode('utf-8')) print(resp.read().decode("utf-8"))
错误:
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/io.py", line 52, in <module>
File "/Users/Yvette/PycharmProjects/2017/201705/abc.py", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 84, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/base64.py", line 9, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 122, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 2, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/types.py", line 171, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/functools.py", line 20, in <module>
ImportError: cannot import name 'get_cache_token'
代码我电脑python3.6能运行成功
是不是没添加python的path?
python遇见数据采集
59669 学习 · 200 问题
相似问题
回答 4
回答 1