Python ascii() Function

Example

Escape Non-ASCII Characters:

x = ascii("My name is Ståle")

Running Example

Definition and Usage

The ascii() function returns a readable version of any object (string, tuple, list, etc.).

The ascii() function will replace all non-ascii characters with escape characters:

å will be replaced with \xe5.

Syntax

ascii(object)

Parameter Value

Parameter Description
object Objects, such as strings, lists, tuples, dictionaries, and so on.