The codecs Module

(New in 2.0) The codecs module provides an interface to the Python codec registry, which holds converters used by the encode and decode string methods.

The module also contains a number of helper functions and classes, including which opens an encoded stream. All data read from the file will be decoded as necessary, and data written to an encoded stream will be encoded.

# File:

import codecs

f ="sample.txt", "r", "iso-8859-1")

print repr(f.readline())


A Django site. rendered by a django application. hosted by webfaction.