python用post访问restful服务接口的方法

yipeiwu_com6年前Python基础

具体代码如下:

import requests
import json
data={"ids": ["00007190","00007191"]}

url="http://XXXXX"
data_json = json.dumps(data)
headers = {'Content-type': 'application/json'}
response = requests.post(url, data=data_json, headers=headers)
print(response.text)

以上这篇python用post访问restful服务接口的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python对于requests的封装方法详解

由于requests是http类接口的核心,因此封装前考虑问题比较多: 1. 对多种接口类型的支持; 2. 连接异常时能够重连; 3. 并发处理的选择; 4. 使用方便,容易维护; 当前...

python opencv图片编码为h264文件的实例

python部分 #!/usr/bin/env Python # coding=utf-8 from ctypes import * from PyQt5.QtCore impo...

python多线程方式执行多个bat代码

python多线程方式执行多个bat的代码,感兴趣的朋友可以参考下。 import threading from win32api import * class MyThread...

Python socket聊天脚本代码实例

这篇文章主要介绍了Python socket聊天脚本代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 没有前端,多开了一条线程用...

python远程登录代码

在 python 中有一个 telnetlib,它的作用就是建立一个通到主机的 telnet连线实体, 然后向主机传送命令 (就...