0
有沒有簡單的方法使用Python上傳單個文件?
我知道requests
,但它發佈了包含單個文件的文件的字典,所以我們在接收另一端的一個文件時遇到了一些問題。在Python中發佈單個文件
目前代碼發送該文件是:
def sendFileToWebService(filename, subpage):
error = None
files = {'file': open(filename, 'rb')}
try:
response = requests.post(WEBSERVICE_IP + subpage, files=files)
data = json.load(response)
(...)
而問題是,requests
發送每個文件中
--7163947ad8b44c91adaddbd22414aff8
Content-Disposition: form-data; name="file"; filename="filename.txt"
Content-Type: text/plain
<beggining of file content>
(...)
<end of file content>
--7163947ad8b44c91adaddbd22414aff8--
我想這是一個文件包。有沒有辦法發送文件「清除」?