Step1 安装requests

pip install requests

Step2 代码

get请求:

import requests

url = 'https://push2.eastmoney.com/api/qt/clist/get?cb=jQuery112308548729516844116_1663424838407&fid=f62&po=1&pz=50&pn=1&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m%3A90+t%3A3&fields=f12%2Cf14%2Cf2%2Cf3%2Cf62%2Cf184%2Cf66%2Cf69%2Cf72%2Cf75%2Cf78%2Cf81%2Cf84%2Cf87%2Cf204%2Cf205%2Cf124%2Cf1%2Cf13'
headers = {'content-type': "application/json"}

response = requests.get(url, headers = headers)
print(response.content)

post请求:

import requests
import json

url = "http://httpbin.org/post"
param = {'key1': 'value1', 'key2': 'value2'}

# 简单地传递一个字典给 data 参数
r = requests.post(url, data=param)

# 传递str 而不是dict,数据会被直接发布出去。
r = requests.post(url, data=json.dumps(param))

print(r.text)
print(r.content)
print(r.url)
print(r.status_code)