更新时间: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" # 从页面获取
request_data = {
    'taskId': taskId,
    'userId': user_name
}
headers = {
    'X-Auth-Token': token,
    'Content-Type': 'application/json'
}
start = time.time()
response = requests.post(url=url, data=json.dumps(request_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