python執(zhí)行g(shù)et提交的方法
更新時間:2015年04月29日 10:02:40 作者:重負在身
這篇文章主要介紹了python執(zhí)行g(shù)et提交的方法,實例分析了Python通過get傳遞數(shù)據(jù)的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了python執(zhí)行g(shù)et提交的方法。分享給大家供大家參考。具體如下:
import sys, urllib2, urllib def addGETdata(url, data): """Adds data to url. Data should be a list or tuple consisting of 2-item lists or tuples of the form: (key, value). Items that have no key should have key set to None. A given key may occur more than once. """ return url + '?' + urllib.urlencode(data) zipcode = 'S2S 7U8' url = addGETdata('http://www.yoursiteweb.com/getForecast', [('query', zipcode)]) print "Using URL", url req = urllib2.Request(url) fd = urllib2.urlopen(req) while 1: data = fd.read(1024) if not len(data): break sys.stdout.write(data)
希望本文所述對大家的Python程序設(shè)計有所幫助。
相關(guān)文章
Python格式化輸出字符串方法小結(jié)【%與format】
這篇文章主要介紹了Python格式化輸出字符串方法,結(jié)合實例形式總結(jié)分析了使用%與format函數(shù)進行字符串格式化操作相關(guān)實現(xiàn)技巧與注意事項,需要的朋友可以參考下2018-10-10OpenCV機器學(xué)習(xí)MeanShift算法筆記分享
這篇文章主要介紹了OpenCV機器學(xué)習(xí)MeanShift算法筆記分享,有需要的朋友可以借鑒參考下,希望可以對各位讀者的OpenCV算法學(xué)習(xí)能夠有所幫助2021-09-09Python常用模塊之threading和Thread模塊及線程通信
這篇文章主要介紹了Python常用模塊之threading和Thread模塊及線程通信,文章為圍繞主題的相關(guān)內(nèi)容展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的朋友看可以參考一下方法2022-06-06使用virtualenv創(chuàng)建Python環(huán)境及PyQT5環(huán)境配置的方法
這篇文章主要介紹了使用virtualenv創(chuàng)建Python環(huán)境及PyQT5環(huán)境配置的方法,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-09-09