【问题标题】:Multipart form encoding file upload in Python 3Python 3 中的多部分表单编码文件上传
【发布时间】:2012-08-11 02:51:17
【问题描述】:

我想知道是否可以在 Python 3 中使用enctype='multipart/form-data' 发布到表单。我环顾四周,只能找到 Python 2 的东西(例如海报)。

【问题讨论】:

    标签: forms post python-3.x multipart


    【解决方案1】:

    使用requests,它支持python 3。

    import requests
    
    response = requests.post('http://httpbin.org/post', files={'file': open('filename','rb')})
    print(response.content)
    

    【讨论】:

      猜你喜欢
      • 2016-04-28
      • 1970-01-01
      • 2016-10-18
      • 1970-01-01
      • 2020-05-27
      • 2016-04-08
      • 2012-04-10
      • 2013-12-08
      • 2020-10-15
      相关资源
      最近更新 更多