#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Auth : test
# @Time : 2020/09/21 11:12
import requests
# 接口的url
url = "http://127.0.0.1:8090/api/xx/xx/search"
header={"ct":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"}
files = {'file':open(r'D:\M000001.wav','rb')}#此处是重点!我们操作文件上传的时候,把目标文件以open打开,然后存储到变量file里面存到一个字典里面
upload_data={"parentId":"","fileCategory":"personal","fileSize":179,"fileName":"M000001.wav","uoType":1}
# 发送接口
upload_res=requests.post(url,upload_data,files=files,headers=header)##此处是重点!我们操作文件上传的时候,接口请求参数直接存到upload_data变量里面,在请求的时候,直接作为数据传递过去
# 打印发送结果
print(upload_res.text)