python3 http提交json参数并获取返回值的方法

时间:2022-06-14 08:20:43

如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import json
import http.client
 
connection = http.client.HTTPSConnection('spd.aiopos.cn')
 
headers = {'Content-type': 'application/json'}
 
values = {
 'acct_pan':'6226011****83678',
 'acct_name':'张三',
 'cert_type':'01',
 'cert_id':'37293019****95',
 'phone_num':'1516××××02'
}
 
json_foo = json.dumps(values)
 
connection.request('POST', '/authen/verifi?access_token=e2011a', json_foo, headers)
 
response = connection.getresponse()
print(response.read().decode())

以上这篇python3 http提交json参数并获取返回值的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/lizhe_dashuju/article/details/80592564