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.

Examples

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

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

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

Subscribe to pythoncheatsheet.org

A bullshit free publication, full of interesting, relevant links.