📜  多部分编码器 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:34.015000             🧑  作者: 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})