本文實(shí)例講述了python使用post提交數(shù)據(jù)到遠(yuǎn)程url的方法。分享給大家供大家參考。具體如下:
import sys, urllib2, urllibzipcode = "S2S 1R8"url = 'http://www.yoursiteweb.com/getForecast'data = urllib.urlencode([('query', zipcode)])req = urllib2.Request(url)fd = urllib2.urlopen(req, data)while 1: data = fd.read(1024) if not len(data): break sys.stdout.write(data)希望本文所述對大家的Python程序設(shè)計有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選