unicodedecodeerror'utf codec can' decode bytes in position - invalid dat decode(unicodedecodeerror'utf codec can' decode bytes in position - invalid dat decode('latin ' 'aabaconce you've decoded to unicode stringyou can "convertit to variety of different encoding schemes reallythis simply translates to alternative binary encoding formatsfrom which we can decode again latera unicode string has no unicode type per seonly encoded binary data doess encode('latin- ' ' \xc \xe cs encode('utf- ' ' \xc \ \xc \xa cs encode('utf- ' '\xff\xfea\ \xc \ \ \xe \ \ encode('ascii'unicodeencodeerror'asciicodec can' encode character '\xc in position notice the last test herethe string you encode to must be compatible with the scheme you chooseor you'll get an exceptionhereascii is too narrow to represent characters decoded from latin- bytes even though you can convert to different (compatiblerepresentationsbytesyou must generally know what the encoded format is in order to decode back to strings encode('utf- 'decode('utf- ''aabacs encode('latin- 'decode('latin- ''aabacs encode('latin- 'decode('utf- 'unicodedecodeerror'utf codec can' decode bytes in position - invalid dat encode('utf- 'decode('latin- 'unicodeencodeerror'charmapcodec can' encode character '\xc in position note the last test here again technicallyencoding unicode code points (charactersto utf- bytes and then decoding back again per the latin- format does not raise an errorbut trying to print the result doesit' scrambled garbage to maintain fidelityyou must generally know what format encoded bytes are ins 'aabacx encode('utf- 'decode('utf- ' 'aabacx encode('latin- 'decode('latin- 'ok if encoding matches data any compatible encoding works text