A quest for html.unescape(" ")
This question already has an answer here:
By default, printing containers like tuples , lists and others will use the repr of their items. (In CPython, it was chosen to not implement <container>.__str__ and instead let object.__str__ fill its slot. The __str__ of object will then call tuple.__repr__ which then proceeds to call the repr of the elements it contains. See PEP 3140 for more.)
Calling the repr for a string with escape codes (such as xa0 ) will, in effect, not escape them:
print(repr(a))
'homexa0-xa0study'
To further verify, try print(s[0]) . By providing the str object in position 0 directly, python will invoke its __str__ and escape the hex correctly.
上一篇: python 3.x
