
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
ascii() in Python program
In this tutorial, we are going to learn about the ascii() function.
ascii(object)
ascii(object) function takes one argument and returns a printable representation of the object.
Let's see some examples.
Example
# intializing non printable characters string = '¢' # printing the above character using ascii(object) print(ascii(string))
Output
If you run the above code, you will get the following results.
'\xa2'
Example
# intializing non printable characters name = 'HÃFÆËŽ' # printing the above character using ascii(object) print(ascii(name))
Output
If you run the above code, you will get the following results.
'H\xc3F\xc6\xcb\u017d'
Example
# intializing non printable characters strings = ['HÃFÆËŽ', '®', '©Òpy'] # printing the above character using ascii(object) print(ascii(strings))
Output
If you run the above code, you will get the following results.
['H\xc3F\xc6\xcb\u017d', '\xae', '\xa9\xd2py']
Conclusion
If you have any doubts in the tutorial, mention them in the comment section.
- Related Articles
- Ascii() in python
- Python program to find the sum of Characters ascii values in String List
- Haskell program to print ascii values
- Converting an image to ASCII image in Python
- ASCII art using Python pyfiglet module
- Python – Filter Strings within ASCII range
- Program to convert ASCII to binary in 8085 Microprocessor
- Program to convert ASCII to HEX in 8085 Microprocessor
- Program to convert HEX to ASCII in 8085 Microprocessor
- 8085 Program to convert ASCII to HEX
- 8085 Program to convert HEX to ASCII
- 8085 Program to convert ASCII to binary
- C++ program to implement ASCII lookup table
- C Program to print all ASCII values.
- Java Program to Print the ASCII values

Advertisements