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--
我想这是一个文件包。有没有办法发送文件“清除”?