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得到单词模式的示例

python得到单词模式的示例

如下所示: def getWordPattern(word): pattern = [] usedLetter={} count=0 for i in word: if i...

numpy找出array中的最大值,最小值实例

在python中利用numpy创建一个array, 然后我们想获取array的最大值,最小值。可以使用一下方法: 一、创建数组 这样就可以获得一个array的最大值和最小值了。 并且可以...

python读取有密码的zip压缩文件实例

python读取有密码的zip压缩文件实例

今天试了一下用zipfile模块读取有密码的zip压缩文件。 今天用winrar 5.6将一个名字为1.xlsx的excel文件打包成1.zip压缩包。采用默认的压缩算法(没有勾选传统加...

Python的设计模式编程入门指南

Python的设计模式编程入门指南

有没有想过设计模式到底是什么?通过本文可以看到设计模式为什么这么重要,通过几个Python的示例展示为什么需要设计模式,以及如何使用。 设计模式是什么? 设计模式是经过总结、优化的,对我...

对numpy中shape的深入理解

环境:Windows, Python2.7 一维情况: <span style="font-size:14px;">>>> import numpy a...