python使用post提交數(shù)據(jù)到遠程url的方法
來源:易賢網(wǎng) 閱讀:1668 次 日期:2015-04-30 13:34:49
溫馨提示:易賢網(wǎng)小編為您整理了“python使用post提交數(shù)據(jù)到遠程url的方法”,方便廣大網(wǎng)友查閱!

這篇文章主要介紹了python使用post提交數(shù)據(jù)到遠程url的方法,涉及Python使用post傳遞數(shù)據(jù)的相關技巧,需要的朋友可以參考下

本文實例講述了python使用post提交數(shù)據(jù)到遠程url的方法。分享給大家供大家參考。具體如下:

import sys, urllib2, urllib

zipcode = "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程序設計有所幫助。

更多信息請查看IT技術專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:python使用post提交數(shù)據(jù)到遠程url的方法
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)