Ascii () function in Python
In Python, the ascii () function returns a string containing the representation of the object that can print. It ignores non-ASCII values in the string using x, u or U.
Syntax of ascii () function in Python:
ascii(object)
Parameters of ascii () function:
The function ascii () has only one object parameter (such as string, list, .).
What value does the function ascii () return?
It returns a string containing the representation of the object that is printable.
For example, ö will be converted to xf6, √ will become u221a, Š will become u0152.
Values other than ASCII will be replaced by x, u or U.
Example of ascii () function:
In the example below, we will try some ASCII characters and see what the ascii () function will return:
danhsach = ['Python','PŸTHON','√', 'ö','Pythön', 'Š', 'Œ','Ž',10, '©']
print(ascii(danhsach))
After running the above program, we get the following output:
['Python', 'Pu0178THON', 'u221a', 'xf6', 'Pythxf6n', 'u0160', 'u0152', 'u017d', 10, 'xa9']
You can see a list of built-in Python functions and don't forget to do Python exercises to reinforce your knowledge.
You should read it
- ASCII function in SQL Server
- What is ASCII? The ASCII code is standard and complete
- The ord () function in Python
- CHAR function in SQL Server
- Int () function in Python
- The function dir () in Python
- Max () function in Python
- Zip () function in Python
- DATENAME function in SQL Server
- The function id () in Python
- Exec () function in Python
- The compile () function in Python