python

关注公众号 jb51net

关闭
首页 > 脚本专栏 > python > python3 http提交json参数并获取返回值

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

作者:药杉

今天小编就为大家分享一篇python3 http提交json参数并获取返回值的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

如下所示:

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参数并获取返回值的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文