ascii()is a function that encodes output repr()to use escape sequences for any code point in the output created repr()that is not in the ASCII range.
So, Latin code 1, such as ë, is represented in its place by the Python escape sequence \xeb.
This is the standard view in Python 2; Python 3 repr()leaves most Unicode codes as their actual output if it is a printable character:
>>> print(repr('ë'))
'ë'
>>> print(ascii('ë'))
'\xeb'
Both outputs are valid Python string literals, but the latter only uses ASCII characters, while the former requires Unicode-compatible encoding.
Unicode U + 0100 U + FFFF \uxxxx escape- , - \Uxxxxxxxx. . escape- Python.
repr(), ascii() - , . repr(), ascii() Unchode .
- , ; ë : U + 00EB ASCII e diaeresis ¨ ( U + 0308):
>>> import unicodedata
>>> one, two = 'ë', unicodedata.normalize('NFD', 'ë')
>>> print(one, two)
ë ë
>>> print(repr(one), repr(two))
'ë' 'ë'
>>> print(ascii(one), ascii(two))
'\xeb' 'e\u0308'
ascii() , two .