Python ascii() method is used to return human-readable versions of the specified data like list, tuple, dictionary, etc. The ascii() method simply converts provided data into the ASCII representation by using the ASCII table.
ascii() Method Syntax
The ascii() method has very simple syntax.
ascii(OBJECT)
- OBJECT is the data type like string, list, tuple etc. we want to print in ASCII. This parameter is required.
Print Using ASCII Encoding
Different types of data can be printed in ASCII encoding. In the following examples we will print the string, list, integer data in ASCII encoding.
a="pythontect"
b=[1,2,3]
c=12
d="Öçş"
print(ascii(a))
print(ascii(b))
print(ascii(c))
print(ascii(d))