str.encode
encode([encoding[,errors]])
Return 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. The default for errors is 'strict',
meaning that encoding errors raise a UnicodeError exception. Other
possible values are 'ignore', 'replace', 'xmlcharrefreplace',
'backslashreplace' and any other name registered via
codecs.register_error, see section [3.8.1][14]. For a list of possible
encodings, see section [3.8.3][15]. New in version 2.0. Changed in
version 2.3: Support for 'xmlcharrefreplace' and
'backslashreplace' and other error handling schemes added.