python post上传文件

python post上传文件

 

import requests
import json
url = 'http://cnbim.com/upload'
file_path = 'path/1/2/file.jpg'
data = {
    'file': open(file_path, 'rb'),
    'id': 's1',
    # add other fields as needed
}
r = requests.post(url, json=data)
print(r.text)

 

 

 

########################

posted @ 2023-08-31 08:32  西北逍遥  阅读(135)  评论(0编辑  收藏  举报