logo

Python String Decode() Method


Show

Description

The count() method in Python String returns the number of occurrences of substring sub in the range [start, end]. Optional arguments start and end are interpreted as in slice notation.

Syntax

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

Parameters

  • encoding - These are the encodings to be used. For a list of every encoding scheme, one shall visit the Standard Encodings.
  • errors - This might be given to help set various error handling schemes. The default for the errors is strict, which signifies that encoding errors may raise a UnicodeError. Other possible values are inclusive of replace, ignore, xmlcharrefreplace, backslashreplace as well as any other name which is registered through codecs.register_error().

Return Value

Decoded 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')

Result

Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=
Decoded String: this is string example....wow!!!

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.