Update apiMethod.py

This commit is contained in:
Leozhanggg 2021-09-01 13:56:40 +08:00
parent badda99595
commit b102a0fc46
1 changed files with 5 additions and 5 deletions

View File

@ -22,17 +22,17 @@ def post(headers, address, mime_type, timeout=10, data=None, files=None, cookies
:param mime_type: 请求参数格式form_data,raw
:param timeout: 超时时间
:param data: 请求参数
:param files: 文件路径
:param files: 上传文件请求参数dict
:param cookies:
:return:
"""
# 判断请求参数类型
if 'form_data' in mime_type:
for i in files:
value = files[i]
for key in files:
value = files[key]
# 判定参数值是否为文件,如果是则替换为二进制值
if '/' in value:
file_parm = i
files[file_parm] = (os.path.basename(value), open(value, 'rb'))
files[key] = (os.path.basename(value), open(value, 'rb'))
enc = MultipartEncoder(
fields=files,
boundary='--------------' + str(random.randint(1e28, 1e29-1))