Python:requests发送json格式数据

import requests
import json
 
data = {
    'a': 123,
    'b': 456
}
 
# headers中添加上content-type这个参数,指定为json格式
headers = {'Content-Type': 'application/json'}
 
# 将数据包转换成json格式
response = requests.post(url='url', headers=headers, data=json.dumps(data))

猜你喜欢

转载自www.cnblogs.com/ScarecrowMark/p/11529634.html