Reputation: 962
code:
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()
the question I encounter is why the two 'print' output the same content, where is problem in my code?
Upvotes: 0
Views: 118
Reputation: 38247
The second argument to urlopen is data to be POSTed. If you want URL arguments you need to create the URL:
print urllib2.urlopen("%s?%s" % (url,urllib.urlencode({'nothing':12345}))).read()
Upvotes: 1