if we print byte objectany bytes that map to ascii representations will be printed as their original characterwhile non-ascii bytes (whether they are binary data or other charactersare printed as hex codes escaped by the \ escape sequence you may find it odd that byterepresented as an integercan map to an ascii character but ascii is really just code where each letter is represented by different byte patternand thereforea different integer the character "ais represented by the same byte as the integer which is the hexadecimal number specificallyall of these are an interpretation of the binary pattern many / operations only know how to deal with byteseven if the bytes object refers to textual data it is therefore vital to know how to convert between bytes and unicode the problem is that there are many ways to map bytes to unicode text bytes are machine-readable valueswhile text is human-readable format sitting in between is an encoding that maps given sequence of bytes to given sequence of text characters howeverthere are multiple such encodings (ascii is only one of themthe same sequence of bytes represents completely different text characters when mapped using different encodingssobytes must be decoded using the same character set with which they were encoded it' not possible to get text from bytes without knowing how the bytes should be decoded if we receive unknown bytes without specified encodingthe best we can do is guess what format they are encoded inand we may be wrong converting bytes to text if we have an array of bytes from somewherewe can convert it to unicode using the decode method on the bytes class this method accepts string for the name of the character encoding there are many such namescommon ones for western languages include asciiutf- and latin- the sequence of bytes (in hex) actually represents the characters of the word cliche in the latin- encoding the following example will encode this sequence of bytes and convert it to unicode string using the latin- encodingcharacters '\ \ \ \ \ \xe print(charactersprint(characters decode("latin- ")