Python ascii() function

Published February 17, 2022

ASCII is a character encoding system that represents English characters with integers ranging from 0 to 127.
In Python, the ascii() function provides a string holding a printable representation of objects, including non-alphabet or invisible characters such as carriage, tab, form feed, and so on. It uses the x, u, or U escapes to escape non-ASCII characters in the string.

The syntax of the ascii() function
The ascii() function is implemented as follows

ascii(object)

The method only accepts one argument, which may be a string, list, dictionary, or any other.


Example
 

a = '''I
Love
Python'''
print("With ascii function : ",ascii(a))
print("Without ascii function : ",a)


Output

With ascii function :  'I\nLove\nPython'
Without ascii function :  I
Love
Python

 

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

266 Views