- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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'
Advertisements