In this tutorial, we will learn about the ascii in python programming language with the help of examples.
Python acsii() function
The function in python is used to return any object in readable or printable version. And if there is any non-ascii character then the python ascii function will replace that character with the escape character like \x, \u, \U etc.
Parameter of ascii() function in python
Return value of Python ascii() function
• It return any object in readable or printable version.
• If there is any non-ascii character then it will replace that character with the escape character like \x, \u, \U etc.
• For example- √ is replaced with \u221a.
Python ascii() Function Examples
Example 1: Displaying ASCII value from the given string
str = "A ñ s w ê r s j ē t"print (ascii(str))
'A \xf1 s w \xea r s j \u0113 t'
Example 2: Taking variable with multiline string and pass it into the ascii()
str = '''Python