Skip to content
Built-in Functions

ascii()

Return a printable representation using ASCII escape sequences.

ascii(object)

ascii() is like repr(), but it replaces non-ASCII characters with escape sequences. This can make text safe to display in ASCII-only places.

Parameters

NameDescription
objectAny object to represent as an ASCII-only string.

Returns

A string containing an ASCII-safe representation of the object.

Try it

Run it and change it
word = "café"
print(ascii(word))

Related entries