sys platform 'win sys getdefaultencoding('utf- underlying platform default encoding for str here bytes(stypeerrorstring argument without an encoding str( " 'spam'len(str( ) len(str(bencoding='ascii') str without encoding print stringnot conversionuse encoding to convert to str when in doubtpass in an encoding name argument in xeven if it may have default conversions are similar in python xthough ' support for mixing string types in expressions makes conversions optional for ascii textand the tool names differ for the different string type model--conversions in occur between encoded str and decoded unicoderather than ' encoded bytes and decoded strs 'spamu 'eggssu ('spam' 'eggs'unicode( )str( ( 'spam''eggs' decode() encode(( 'spam''eggs' type string conversion tools converts str->uniuni->str versus byte->strstr->bytes coding unicode strings encoding and decoding become more meaningful when you start dealing with nonascii unicode text to code arbitrary unicode characters in your stringssome of which you might not even be able to type on your keyboardpython string literals support both "\xnnhex byte value escapes and "\unnnnand "\unnnnnnnnunicode escapes in string literals in unicode escapesthe first form gives four hex digits to encode -byte ( -bitcharacter code pointand the second gives eight hex digits for -byte ( -bitcode point byte strings support only hex escapes for encoded text and other forms of byte-based data coding ascii text let' step through some examples that demonstrate text coding basics as we've seenascii text is simple type of unicodestored as sequence of byte values that represent charactersc:\codec:\python \python ord(' ''xis binary code point value in the default encoding unicode and byte strings