python之requests

2021/6/13 20:21:16

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

import requests
url='http://192.168.3.4/php/executeCommand.php'#请求url
update_data={'jsondata[shell]': 'upgrade.sh','jsondata[command]': 'system'}#请求体
res=requests.post(url,update_data)
print(res.text)#http响应内容的字符串形式,即返回的页面内容
print(res.json())#http响应的json格式
print(res.status_code)#http请求的返回状态,若为200则表示请求成功
print(res.encoding)#从http header 中猜测的相应内容编码方式
print(res.content)#http响应内容的二进制形式
print(res.apparent_encoding)#从内容中分析出的响应内容编码方式(备选编码方式)


这篇关于python之requests的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程