前言:注冊接口需要上次頭像,fiddle抓的接口如圖,這個時候就需要用到:files

2,舉例說明
a:有一個上傳接口,地址如下:http://xx.xx.xx.xx//upload/stream
b:上傳接口的參數如下所示:{"parentId":"","fileCategory":"personal","fileSize":179,"fileName":"summer_text_0920.txt","uoType":1}
3、發送請求,代碼如下所示:
header={"ct":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"}
files = {'file':open('D:\\test_data\\summer_test_data_05.txt','rb')}#此處是重點!我們操作文件上傳的時候,把目標文件以open打開,然后存儲到變量file里面存到一個字典里面
upload_data={"parentId":"","fileCategory":"personal","fileSize":179,"fileName":"summer_text_0920.txt","uoType":1}
upload_res=requests.post(upload_url,upload_data,files=files,headers=header)##此處是重點!我們操作文件上傳的時候,接口請求參數直接存到upload_data變量里面,在請求的時候,直接作為數據傳遞過去
4、運行結果

