Update apiMethod.py
This commit is contained in:
parent
badda99595
commit
b102a0fc46
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue