
- 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
ASCII is abbreviated from of American Standard Code for Information Interchange. It is a character encoding standard. For example the ASCII value of English alphabet A is 65. Python provides this function to get the printable representation of an object. It takes one parameter which is an object that can be a list, strings, tuple etc. The output of the function is the hex representation. The non-ascii characters can be escaped using \x, \u or \U escapes.
Syntax
The syntax is −
Syntax: ascii(object)
Example
Printing strings with individual characters and multiple characters.
# Individual Characters print(ascii("Ω")) print(ascii("θ")) # A string int multiple characters print(ascii("TΨtΦrial"))
Output
Running the above code gives us the following result −
'\u03a9' '\u03b8' 'T\u03a8t\u03a6rial'
- Related Articles
- ascii() in Python program
- Converting an image to ASCII image in Python
- ASCII art using Python pyfiglet module
- Python – Filter Strings within ASCII range
- Map function and Dictionary in Python to sum ASCII values
- How to check if a string in Python is in ASCII?
- Convert between binary and ASCII using Python (binascii)
- How to convert an integer to an ASCII value in Python?
- How to Find ASCII Value of Character using Python?
- ASCII to hex and hex to ASCII converter class in JavaScript
- ASCII NUL, ASCII 0 (‘0’) and Numeric literal 0?
- Get ASCII table in Arduino
- Python program to find the sum of Characters ascii values in String List
- ASCII vs. UNICODE
- Hex to ASCII conversion in 8051

Advertisements