by Walkman · 9y ago · 0 comments
If you make it not print strings as "ascii" but as hex, people grasp the difference easier.
Better say "bytes are not Unicode strings".
>>> b'asd'[0]
97
>>> b'asd'[1]
115
>>> b'asd'[2]
100
They happen to contain an ASCII DECODABLE string in this case, but to get the text back, you NEED TO decode it first: >>> text = b'asd'.decode()
>>> text[0]
'a'
>>> text[1]
's'
>>> text[2]
'd'