Web | This Site

Python Basics
Python Advanced
Python Useful References
Python Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Python String decode() Method

## Description:

This method decodes the string using the codec registered for encoding. encoding defaults to the default string encoding.

## Syntax:

    str.decode(encoding='UTF-8',errors='strict')

## Parameters:

Here is the detail of parameters:

- encoding: is the encodings to be used. For a list of all encoding schemes please visit: Standard Encodings.

- errors : may be given to set a different error handling scheme. The default for errors is 'strict', meaning that encoding errors raise a UnicodeError. Other possible values are 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' and any other name registered via codecs.register_error().

## Return Value:

It returns an decoded version of the string.

## Example:

    #!/usr/bin/python

    str = "this is string example....wow!!!";
    str = str.encode('base64','strict');

    print "Encoded String: " + str;
    print "Decoded String: " + str.decode('base64','strict')

This will produce following result:

    Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=

    Decoded String: this is string example....wow!!!

Advertisement

Online Image Processing

Indian Baby Names