使用Python提交文件
发布时间
阅读量:
阅读量
具体实现代码如下:
def upload_zip_file(file_absolute_path):
file_name = os.path.split(file_absolute_path)[-1]
upload_bug_file = (file_name, open(file, 'rb'), 'application/zip')
m = MultipartEncoder(
fields={'file_name': file_name, 'file_path': upload_bug_file}
)
print("脚本上传文件:%s" % file)
resp = requests.post(url=SERVER_IP + UPLOAD_FILE, data=m, headers={'Content-Type': m.content_type})
print("上传file -=-=- status_code: %s, resp_text: %s" % (resp.status_code, resp.text))
上传参数
在fields中定义了(‘file_name’,‘file_path’)这两个参数作为映射关系,并且这些参数对应的正是api要求上传到r
全部评论 (0)
还没有任何评论哟~
