Python ascii() Method
Python ascii() method is a built-in method. It returns string representation of an object and escape the non-ASCII characters in the string by using \x, \u or \U escapes.
Basically, It returns a readable string version of an object by replacing non-ASCII characters.
|object||(Required) This argument can be a list, string, integer etc.|
It returns string representation of an object by replacing all non-ASCII characters.
Python ascii() Method Example
Let’s first understand, how this method works and what does it return?
As you can see, in the above example, first value is an ascii-char string and second value is non-ascii string. So, Python interpreter prints first value as it is but replaced second-one by the escape characters.