python request库学习 二 post请求

2021/5/20 12:27:33

本文主要是介绍python request库学习 二 post请求,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

#post请求

import requests

#1.post请求带数据
data={‘name’:‘germey’,‘age’:22}
response = requests.post(‘http://httpbin.org/post’,data=data)
print(response.text)

#2.post 请求带数据和头部headers

data={‘name’:‘germey’,‘age’:22}
headers={‘User-Agent’:‘Mozilla/5.0(Windows NT 6.1; Win64; x64) AppleWebKit/537.36(KHTML,like Gecko) Chrome/90.0.4430.93 Safari/537.36’}
response = requests.post(‘http://httpbin.org/post’,data=data,headers)
print(response.text)



这篇关于python request库学习 二 post请求的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程