加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
API接口压力测试.py 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
root 提交于 2022-06-09 16:19 . add API接口压力测试.py
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 9 15:40:34 2022
@author: fengmingshan
"""
import requests
import time
import json
url = 'http://61.166.128.245:9001/subscribe/'
# 以字典的形式构造数据
district= ['锦林小区' for x in range(2000)]
firstName = ['欧阳' for x in range(2000)]
gender = ['先生' for x in range(2000)]
building = ['一栋' for x in range(2000)]
unit = ['一单元' for x in range(2000)]
floor = [1 for x in range(2000)]
room = ['1-1-201' for x in range(2000)]
subscribeDate = ['2022年10月1日 17点' for x in range(2000)]
telephone = ['13378749267' for x in range(2000)]
for d,f,g,b,u,fl,r,s,t in zip(
district,
firstName,
gender,
building,
unit,
floor,
room,
subscribeDate,
telephone,
):
data = {
'district': d,
'firstName': f,
'gender': g,
'building': b,
'unit': u,
'floor': fl,
'room': r,
'subscribeDate': s,
'telephone': t,
}
time.sleep(0.5)
# 与 get 请求一样,r 为响应对象
r = requests.post(url, data=json.dumps(data))
# 查看响应结果
print(r.json())
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化