kv = {"key1":"value1","key2":"value2"} r = request.request("POST","http://pythton123.io/ws",data=kv) body = "主体内容" r = request.request("POST","http://pythton123.io/ws",data=body)
json将JSON格式的数据作为requests的内容
1 2
kv = {"key1":"value1","key2":"value2"} r = request.request("POST","http://pythton123.io/ws",json=kv)
headers定制HTTP头部中的内容
1 2
hd = {'user‐agent': 'Chrome/10'} r = requests.request('POST', 'http://python123.io/ws', headers=hd)
cookies
files字典类型,传输文件,值要用open()函数
1 2
fs = {'file': open('data.xls', 'rb')} r = requests.request('POST', 'http://python123.io/ws', files=fs)
auth
timeout超时设置(秒为单位)
1
r = requests.request('GET', 'http://www.baidu.com', timeout=10)