Python ascii() Function Syntax

Syntax: ascii(object)

  • object: Any Python object (ex.: string, int, list, tuple, set, etc.)

Returns: Returns a string as a printable representation of the object passed, escaping the non-ASCII characters.

The method can take only one parameter, an object that can be a list, strings, etc. As already discussed, it returns a printable representation of an object.

ascii() in Python

In Python, we have ascii() function that returns a string containing a printable representation of an object. In this article, we will see about ascii() in Python.

Similar Reads

Python ascii() Function

Python ascii() function returns a string containing a printable representation of an object and escapes the non-ASCII characters in the string using \x, \u or \U escapes. It’s a built-in function that takes one argument and returns a string that represents the object using only ASCII characters....

Python ascii() Function Syntax

Syntax: ascii(object) object: Any Python object (ex.: string, int, list, tuple, set, etc.) Returns: Returns a string as a printable representation of the object passed, escaping the non-ASCII characters....

Usage of Python ascii() Function

We see that in these examples, all the non-ASCII characters have been escaped, i.e. their encoded code gets displayed by using the ascii() method....