input and output and is one of more than hundred different character encodings the following valueshoweverare most commonvalue description 'ascii'latin- or 'iso- - -bit ascii iso - latin- windows encoding -bit variable-length encoding -bit variable-length encoding (may be little or big endianutf- little endian encoding utf- big endian encoding same format as unicode literals "stringsame format as raw unicode literals ur"string'cp 'utf- 'utf- 'utf- -le'utf- -be'unicode-escape'raw-unicode-escapethe default encoding is set in the site module and can be queried using sys getdefaultencoding(in many casesthe default encoding is 'ascii'which means that ascii characters with values in the range [ , fare directly mapped to unicode characters in the range [ + + fhowever'utf- is also very common setting technical details concerning common encodings appears in later section when using the decode(methodit is always assumed that is string of bytes in python this means that is standard stringbut in python must be special bytes type similarlythe result of encode(is always byte sequence one caution if you care about portability is that these methods are little muddled in python for instancepython strings have both decode(and encode(methodswhereas in python strings only have an encode(method and the bytes type only has decode(method to simplify code in python make sure you only use encode(on unicode strings and decode(on byte strings when string values are being converteda unicodeerror exception might be raised if character that can' be converted is encountered for instanceif you are trying to encode string into 'asciiand it contains unicode character such as + you will get an encoding error because this character value is too large to be represented in the ascii character set the errors parameter of the encode(and decode(methods determines how encoding errors are handled it' string with one of the following valuesvalue description 'strictraises unicodeerror exception for encoding and decoding errors ignores invalid characters replaces invalid characters with replacement character ( +fffd in unicode'?in standard stringsreplaces invalid characters with python character escape sequence for examplethe character + is replaced by '\ replaces invalid characters with an xml character reference for examplethe character + is replaced by '&# ;'ignore'replace'backslashreplace'xmlcharrefreplacef lib fl ff