Easy Tutorial
❮ Python Func Frozenset Python Os Rename ❯

Python3 ascii() Function

Python3 Built-in Functions


Description

The ascii() function is similar to the repr() function, returning a string that represents an object. However, for non-ASCII characters in the string, it returns characters encoded using \x, \u, or \U as used by the repr() function. The generated string resembles the return value of the repr() function in Python2.


Syntax

Here is the syntax for the ascii() method:

ascii(object)

Parameters


Return Value

Returns a string.


Example

The following demonstrates the use of the ascii() method:

>>> ascii('tutorialpro')
"'tutorialpro'"

Python3 Built-in Functions

❮ Python Func Frozenset Python Os Rename ❯