更新时间:2021-09-18 GMT+08:00
分享

Python代码样例

Python代码样例,如下所示:

"""
用户需要根据实际情况填写user_name, password, taskId, url, data的值
"""
import json
import time
from pprint import pprint

import requests

user_name = "xxx_xxxx"
password = "xxxxxx"
token ="xxxxxx" # 根据文档从获取token的接口中取到
taskId = 0 # 从页面获取
url = "xxxxx" # 从页面获取

data = 
{
    "taskId": taskId ,
    "userId": user_name ,
    "datas": 
      [{"diskSn":"test",
	"predictDate":"20200212",
	"predictResult":"correct",
	"predictDesc":"test"
        },
	{"diskSn":"test2",
	"predictDate":"20200212",
	"predictResult":"error",
	"predictDesc":"test2"
        }]
}
headers = {
    'X-Auth-Token': token,
    'Content-Type': 'application/json'
}
start = time.time()
response = requests.post(url=url, data=json.dumps(data),
                         headers=headers, verify=False)
end = time.time()

try:
    pprint(json.loads(response.text))
    print(f'predict cost time: {end-start:.4f} s')
except:
    print(response.text)
    print(f'predict cost time: {end-start:.4f} s')
分享:

    相关文档

    相关产品

close