Python ascii() built-in function

From the Python 3 documentation

As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by repr() using \x, \u, or \U escapes.


>>> ascii('A')
# 'A'

>>> ascii('ë')
# '\xeb'

>>> ascii(['A', 'ë'])
# ['A', '\xeb']

Subscribe to

A two times a month and bullshit free publication, full of interesting, relevant links.