运行报错,求解
按照老师讲的写的代码,报错如下:怎么回事呢?
D:\Python36\python.exe D:/PycharmProjects/urltest/urlpost.py
Traceback (most recent call last):
File "D:/PycharmProjects/urltest/urlpost.py", line 11, in <module>
("SearchWay", "DepartureInMandarin")
TypeError: 'tuple' object is not callable
源代码:
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([
("StartStation", "977abb69-413a-4ccf-a109-0272c24fd490"),
("EndStation", "9c5ac6ca-ec89-48f8-aab0-41b738cb1814"),
("SearchDate", "2017/02/17"),
("SearchTime", "19:00")
("SearchWay", "DepartureInMandarin")
])
req.add_header("Origin", "http://www.thsrc.com.tw")
req.add_header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36")
resp = urlopen(req, data=postData.encode("utf-8"))
print(resp.read().decode("utf_8"))