我認爲當你使用post(我沒有很好地告知這個主題明顯)時,一個帖子發送了所有HTTP頭信息,所以我很困惑你爲什麼必須將數據urlencode()成key=value&key2=value2
格式。如何在使用POST?:當格式化開始發揮作用Python:urllib2.urlopen(url,data)爲什麼你需要urllib.urlencode()數據?
# Fail
data = {'name': 'John Smith'}
urllib2.urlopen(foo_url, data)
但
# Success
data = {'name': 'John Smith'}
data = urllib.urlencode(data)
urllib2.urlopen(foo_url, data)