from requests_toolbelt.multipart import decoder
multipart_string = b"--ce560532019a77d83195f9e9873e16a1
Content-Disposition: form-data; name="author"
John Smith
--ce560532019a77d83195f9e9873e16a1
Content-Disposition: form-data; name="file"; filename="example2.txt"
Content-Type: text/plain
Expires: 0
Hello World
--ce560532019a77d83195f9e9873e16a1--
"
content_type = "multipart/form-data; boundary=ce560532019a77d83195f9e9873e16a1"
for part in decoder.MultipartDecoder(multipart_string, content_type).parts:
print(part.text)
John Smith
Hello World