about urllib.encode & urlopen(url,data,timeout) function

本文介绍如何利用Python中的urllib.urlencode函数正确处理HTTP请求的数据参数。当需要发送包含多个键值对的数据时,可以先将这些键值对存储在一个字典中,然后通过urllib.urlencode函数进行编码,最后作为参数传递给urllib2.urlopen()函数完成请求。如果数据已经是正确的格式,如'a=1&b=2',则不需要再次使用urlencode。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

the data argument is form like belows:

a=1&b=2

this character is use urllib.urlencode concat together

use a dict

e.g.

dict={}

dict["a"]=1

dict["b"]=2

data=urllib.urlencode(dict)

 

if you already has a form like a=1&b=2

then your did not use the urllib.urlcode function

i was made a mistake when google some blog same how to use urllib2.urlopen() follow the urllib.urlencode way

in fact my data is alreay the well format

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值