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分析nignx访问日志脚本分享

#!/usr/bin/env python # coding=utf-8 #-------------------------------------------------...

创建pycharm的自定义python模板方法

在pycharm上依次选择打开File->settings->Editor->File andCode Templates->Python Script 复制以下...

PyTorch的深度学习入门之PyTorch安装和配置

PyTorch的深度学习入门之PyTorch安装和配置

前言 深度神经网络是一种目前被广泛使用的工具,可以用于图像识别、分类,物体检测,机器翻译等等。深度学习(DeepLearning)是一种学习神经网络各种参数的方法。因此,我们将要介绍的深...

在Pycharm中项目解释器与环境变量的设置方法

1.官网下载Pycharm community版如pycharm-community-2017.3.1.tar.gz。 2. #解压tar.gz tar xfz pycharm-*.ta...

python写入文件自动换行问题的方法

python写入文件自动换行问题的方法

现在需要一个写文件方法,将selenium的脚本运行结果写入test_result.log文件中 首先创建写入方法 def write_result(str): writeres...