今天快坑死我了,网上讲这个的特别少,难道大家都不用这个吗?废话不多说,上干货。
发送application/json数据
这个比较简单,我这里不需要什么headers 和cookie,需要的朋友去这里看:https://www.cnblogs.com/wtcl/p/9006709.html
url_weather = "www.baidu.com/****" # 这就是你的请求路由
params = {
"a": {
"b":1
}
} # 这里就是你的json数据
data = requests.post(url_weather, json=params).text # 这样就可以发送给请求了,.text用来读取返回的数据的
发送application/x-www-form-urlencoded数据
url_weather = "http://" # 请求路由
requestdata = {"jsonString":'{"name":"%s","date":"%s","limit":%d}'%(city_name_dict[projectId],start_time,num)} # 关键都在这里了,一定要仔细看
data = requests.post(url_weather,data=requestdata).text
一定要仔细看这一段数据
{"jsonString":'{"n