Javatpoint Logo
Javatpoint Logo

Python ascii() Method

Python ascii() method is used to get string representation of an object. This method takes an argument of object type and escapes all the non-ASCII characters from the string object. The signature of this function is given below.



object: object like list, string etc.


It returns a string containing printable representation of an object.

Let's see some examples of ascii() method to understand it's functionality.

Python ascii() Method Example 1

This example handles the non-ASCII value and prints its string representation.



Python ascii() Method Example 2

A string which contains non-ASCII chars will produce some different output for these elements. See the example.


'W\xa3lcom\xa3 to J\xe0v\xe0tpoint\xb6'

Python ascii() Method Example 3

If a string does not contain any non-ASCII character, it simply returns its printable value. See the example below.



Next TopicPython Functions

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA