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

yipeiwu_com5年前Python基础

如下所示:

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参数并获取返回值的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python RuntimeError: thread.__init__() not called解决方法

在写一个多线程类的时候调用报错 RuntimeError: thread.__init__() not called 复制代码 代码如下: class NotifyTread(thre...

Form表单及django的form表单的补充

Form表单及django的form表单的补充

form 表单中的button按钮 <button>提交</button> :放在form表单中,会有一个提交事件,会提交form数据, <input ty...

numpy:找到指定元素的索引示例

目的:在numpy数组中知道指定元素的索引 函数: np.argwhere >>>x >>>array([[0, 1, 2], [3, 4,...

Python基础中所出现的异常报错总结

Python基础中所出现的异常报错总结

今天我们来探索python中大部分的异常报错 首先异常是什么,异常白话解释就是不正常,程序里面一般是指程序员输入的格式不规范,或者需求的参数类型不对应,不全等等。 打个比方很多公司年终...

python如何定义带参数的装饰器

本文实例为大家分享了python定义带参数装饰器的具体代码,供大家参考,具体内容如下 案例:        实现一个装饰器,用...