1、return返回json格式的对象
2、返回的响应解析成json的方式,可以防止函数的外面,也可以放在里面
def showSubmit():
#查看处理
url = "http://exp.aacom/dragon/flow/showSubmit"
params = {
"recordId":"RE080987801_103865_QE9FT1",
"t":1596101206,
"sign":"00140ea1e316d162e3603647570d7476"
}
headers = {'content-type': 'application/json'}
ret = requests.post(url, data=json.dumps(params), headers=headers, cookies=cookies)
d1 = json.loads(ret.text)
print(d1)
def load_picture(url_load,open_url):
#上传图片
url = url_load
# url = "http://exp.aa.com/dragon/file/upload"
params = {}
headers = {'content-type': 'application/json'}
files = {'file_data': open(open_url, 'rb')}
# open_url = 'C:\\Users\\xiwei\\Desktop\\万科自动化\\交易合同.jpg'
ret = requests.post(url, data=params, files=files, cookies=cookies)
return ret
url_load = "http://exp.aaa.com/dragon/file/upload"
open_url = 'C:\\Users\\xiwei\\Desktop\\万科自动化\\交易合同.jpg'
result = load_picture(url_load,open_url)
result_json = json.loads(result.text)
print(result)
fileId = result_json["data"]["fileId"]
fileName = result_json["data"]["fileName"]
filePath = result_json["data"]["filePath"]
print(fileId)
print(fileName)
print(filePath)
原文链接:https://blog.csdn.net/romon19/article/details/107706413