Home > Articles > Open Source > Python

Python Libraries

  • Print
  • + Share This

Internet Data Handling

This group covers modules that support encoding and decoding of data handling formats and that are largely used in Internet applications.

For more details and examples about using these modules, see Chapter 13, "Data Manipulation."


The sgmllib module is an SGML (Standard Generalized Markup Language) parser subset. Although it has a simple implementation, it is powerful enough to build the HTML parser.


The htmllib module defines a parser for text files formatted in HTML (Hypertext Markup Language).


The htmlentitydefs module is a dictionary that contains all the definitions for the general entities defined by HTML 2.0.


The xmllib module defines a parser for text files formatted in XML (Extensible Markup Language).


The formatter module is used for generic output formatting by the HTMLParser class of the htmllib module.


The rfc822 module parses mail headers that are defined by the Internet standard RFC 822. The headers of this form are used in a number of contexts including mail handling and in the HTTP protocol.


The mimetools module provides utility tools for parsing and manipulation of MIME multipart and encoded messages.


MIME (multipurpose Internet mail extensions) is a standard for sending multipart multimedia data through Internet mail.


The MimeWrite module implements a generic file-writing class that is used to create MIME-encoded multipart files.


The multifile module enables you to treat distinct parts of a text file as file-like input objects. Usually, this module uses text files that are found in MIME encoded messages.


The binhex module encodes and decodes files in binhex4 format. This format is commonly used to represent files on Macintosh systems.


The uu module encodes and decodes files in uuencode format. This module does its job by transferring binary data over an ASCII-only connection.


The binascii module implements methods to convert data between binary and various ASCII-encoded binary representations.


The base64 module performs base64 encoding and decoding of arbitrary binary strings into text strings that can be safely emailed or posted. This module is commonly used to encode binary data in mail attachments.


The xdrlib module is used extensively in applications involving Remote Procedure Calls (RPC). Similarly, it is often used as a portable way to encode binary data for use in networked applications. This module is able to encode and decode XDR data because it supports the external data representation (XDR) Standard.


The mailcap module is used to read mailcap files and to configure how MIME-aware applications react to files with different MIME types.


mailcap files are used to inform mail readers and Web browsers how to process files with different MIME types.


The mimetypes module supports conversions between a filename or URL and the MIME type associated with the filename extension.

Essentially, it is used to guess the MIME type associated with a file, based on its extension, as shown in Table 3.1.

Table 3.1 Some MIME Type Examples

Filename Extension

MIME Type Associated








The quopri module performs encoding and decoding of MIME quoted printable data. This format is primarily used to encode text files.


The mailbox module implements classes that allow easy and uniform access to read various mailbox formats in a UNIX system.


The mhlib module provides a Python interface to access MH folders and their contents.


The mimify module has functions to convert and process simple and multipart mail messages to/from the MIME format.


The netrc module parses, processes, and encapsulates the .netrc configuration file format used by the UNIX FTP program and other FTP clients.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.