import requests
import json
import pandas as pd
list2 = []
false = False
true = True
# post
headers = {"content-type": "charset=utf8"}
url = "url链接"
# 获取 model 列表
df = pd.read_excel("重新测试.xlsx")
list1 = []
for i in df["测试样例"]:
list1.append(i)
test_intent = list1[0]
df = df.iloc[:, 9:]
for col in df.columns:
col = df[col]
for item in col:
item = json.dumps(item)
item = json.loads(item)
item = eval(item)
model = item["键"]
xieyi = item["键"]
data = {
键值对
}
res = requests.post(url=url, data=json.dumps(data), headers=headers)
dict1 = json.loads(res.text)
recordId = dict1["recordId"]
display = dict1["speak"]["display"]
list2.append(
"{"
+ '"结果": false, "recordId": "{}", "smr_reply": "{}", "iotmodel": "{}", "协议": "{}"'.format(
recordId, display, model, xieyi
)
+ "}"
)
df2 = pd.DataFrame(list2)
df2.T.to_excel("output.xlsx", index=False)
标签:批量,recordId,python,item,json,url,df,post
From: https://www.cnblogs.com/tiansz/p/16848439.html