ascii(object)
The ascii() function replaces non-printable characters with their corresponding ASCII values and returns them.
Parameters
The ascii() function takes one parameter:
object: A Python list, set, tuple, etc.
Return Value
- Returns a string representation of
objectwith non-ASCII characters escaped.
Similar to repr(), it returns a string representation of object, but it escapes non-ASCII characters returned by repr() using \x, \u, or \U.
Examples
value = 'mr. Иванов'
repr(value) # 'mr. Иванов'
ascii(value) # 'mr. \u0418\u0432\u0430\u043d\u043e\u0432'