周志洋

个人站

持续学习 才能不被淘汰


Python实用技巧-网络请求基础

基本请求

import requests

response = requests.get('https://httpbin.org/json')
print(response.status_code)
print(response.json())

POST 请求

data = {'key': 'value'}
response = requests.post('https://httpbin.org/post', json=data)

会话管理

session = requests.Session()
session.headers.update({'User-Agent': 'MyApp/1.0'})


转载请注明:周志洋的博客 » Python实用技巧-网络请求基础

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦