Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
代码:
import urllib,urllib2 url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php' print urllib2.urlopen(url).read() print urllib2.urlopen(url,urllib.urlencode({'nothing':12345})).read()
我遇到的问题是为什么两个“打印”输出相同的内容,我的代码哪里有问题?
urlopen 的第二个参数是要发布的数据。如果您需要 URL 参数,则需要创建 URL:
print urllib2.urlopen("%s?%s" % (url,urllib.urlencode({'nothing':12345}))).read()