How to parse multi-part content

Tim Roberts timr at
Sun Sep 26 08:23:23 CEST 2004

Dave Kuhlman <dkuhlman at> wrote:
>Suppose that I have content that looks like what I've included at
>the end of this message.  Is there something in the standard
>Python library that will help me parse it, break into the parts
>separated by the boundary strings, extract headers from each
>sub-part, etc?
>In case you are curious, this is content posted to my Zope server
>when I include an element '<input type="file" .../>' in my form.

Actually, you get this because your <form> header has
enctype="multipart/form-data".  It happens that file upload only works with
that enctype, but you can use it without a file upload.

That's why knows how to parse this.  Look at cgi.parse_multipart.
- Tim Roberts, timr at
  Providenza & Boekelheide, Inc.

More information about the Python-list mailing list