📜  多部分表单数据多部分编码器python代码示例

📅  最后修改于: 2022-03-11 14:46:11.130000             🧑  作者: Mango

代码示例1
from requests_toolbelt import MultipartEncoder
import requests

m = MultipartEncoder(
    fields={'field0': 'value', 'field1': 'value',
            'field2': ('filename', open('file.py', 'rb'), 'text/plain')}
    )

r = requests.post('http://httpbin.org/post', data=m,
                  headers={'Content-Type': m.content_type})