需求
    
    
    需要开发python程序,调用之间java实现的上传文件接口
    
    
     需要包
    
    
    
     requests
    
    
    
     代码
    
   
import requests
url = "https://localhost/uploadPic"
files = {
    "editormd-image-file": ("1.jpeg", open("1.jpeg", "rb"), "multipart/form-data")
}
response = requests.post(url=url, files=files)
print(response.json())
    
     参数说明
    
   
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
        ``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
        or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
        defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
        to add for the file.
    此处我们的
    
     content-type
    
    是
    
     multipart/form-data
    
    
    返回是JSON格式字符串
   
 
版权声明:本文为kh971024原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
