2 ms·
I wouldn't say they are not ASCII strings, because they are if you squint. Better say "bytes are not Unicode strings".
by jstimpfle 10y ago
I wouldn't say they are not ASCII strings, because they are if you squint.
Better say "bytes are not Unicode strings".
- Walkman 10y agoNo, they are NOT strings, they are not any kind of strings. They are bytes: >>> 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'
- jstimpfle 10y agoTechnically true. I'd inferred a different context on this one: By "strings" I meant the abstract concept in this case, not the python str which is the one meant.