Copyright © tutorialspoint.com

Python String decode() Method

previous next


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:

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!!!

previous next

Copyright © tutorialspoint.com