Copyright © tutorialspoint.com

Python String encode() Method

previous next


Description:

This method returns an encoded version of the string. Default encoding is the current default string encoding. errors may be given to set a different error handling scheme.

Syntax:

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

Parameters:

Here is the detail of parameters:

Return Value:

It returns an encoded version of the string.

Example:

#!/usr/bin/python

str = "this is string example....wow!!!";

print "Encoded String: " + str.encode('base64','strict')

This will produce following result:

Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=

previous next

Copyright © tutorialspoint.com