From here:

The function ord() gets the int value of the char. And in case you want to convert back after playing with the number, function chr() does the trick.

>>> ord('a')
97
>>> chr(97)
'a'
>>> chr(ord('a') + 3)
'd'
>>>

In Python 2, there was also the unichr function, returning the Unicode character whose ordinal is the unichr argument:

>>> unichr(97)
u'a'
>>> unichr(1234)
u'\u04d2'

In Python 3 you can use chr instead of unichr.


ord() - Python 3.6.5rc1 documentation

ord() - Python 2.7.14 documentation

Answer from Matt J on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-ascii_letters
ascii_letters in Python - GeeksforGeeks
January 10, 2025 - We may want to count how many ASCII letters are present in a given string. This is a common task when analyzing text data: ... import string s = "Python3.9 is Awesome!" # Counting the number of ASCII letters in the string count = sum(1 for char in s if char in string.ascii_letters) print(count)
🌐
W3Schools
w3schools.com › python › ref_func_ascii.asp
Python ascii() Function
Python Examples Python Compiler ... Bootcamp Python Certificate Python Training ... The ascii() function returns a readable version of any object (Strings, Tuples, Lists, etc)....
🌐
w3resource
w3resource.com › python › built-in-function › ascii.php
Python: ascii() function - w3resource
August 19, 2022 - Python ascii() function: The ascii() function returns a string containing a printable representation (escape the non-ASCII characters) of an object.
🌐
GeeksforGeeks
geeksforgeeks.org › python › ascii-in-python
ascii() in Python - GeeksforGeeks
January 24, 2026 - Python provides the built-in ascii() function to return a printable representation of an object using only ASCII characters.
🌐
Programiz
programiz.com › python-programming › examples › ascii-character
Python Program to Find ASCII Value of Character
Here we have used ord() function to convert a character to an integer (ASCII value).
🌐
Programiz
programiz.com › python-programming › methods › built-in › ascii
Python ascii() (With Examples)
Become a certified Python programmer. Try Programiz PRO! ... The ascii() method replaces a non-printable character with its corresponding ascii value and returns it.
Find elsewhere
🌐
Python
docs.python.org › 3 › library › curses.ascii.html
curses.ascii — Utilities for ASCII characters
A 33-element string array that contains the ASCII mnemonics for the thirty-two ASCII control characters from 0 (NUL) to 0x1f (US), in order, plus the mnemonic SP for the space character. curses — Terminal handling for character-cell displays · curses.panel — A panel stack extension for curses ... © Copyright 2001 Python Software Foundation.
🌐
Tutorialspoint
tutorialspoint.com › python › python_ascii_function.htm
Python ascii() Function
The Python ascii() function is a built-in function that returns a readable version of the specified object. Here, the object could be Strings, Tuples, Lists, etc. If this function encounters a non-ASCII character, it will replace it with an escape
🌐
w3resource
w3resource.com › python-exercises › python-basic-exercise-86.php
Python: ASCII value of letter in Python - w3resource
Python Exercises, Practice and Solution: Write a Python program to get the ASCII value of a character.
🌐
SSOJet
ssojet.com › character-encoding-decoding › ascii-in-python
ASCII in Python | Encoding Standards for Programming Languages
Working with plain text often means dealing with characters that aren't standard English letters. Python's built-in capabilities for handling ASCII characters provide a robust way to process and manipulate this fundamental character encoding. This guide covers how to represent, convert, and work with ASCII values directly in Python.
🌐
AskPython
askpython.com › home › how to use the python ascii() function
How to use the Python ascii() function - AskPython
February 16, 2023 - The ascii() function returns a string representation of the object but only having ASCII characters as it is.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-check-for-ascii-string
Check for ASCII String - Python - GeeksforGeeks
July 11, 2025 - This involves comparing each character's value to ensure it meets the criteria. The simplest way to do this in Python is by using the built-in str.isascii() method, which efficiently checks if all characters in a string belong to the ASCII character ...
🌐
Vultr Docs
docs.vultr.com › python › built-in › ascii
Python ascii() - Convert Object to ASCII | Vultr Docs
September 27, 2024 - The ascii() function in Python is a built-in utility that converts any object into an ASCII string representation. This is particularly useful for rendering readable versions of objects that contain non-ASCII text, such as special characters ...
🌐
Vultr
docs.vultr.com › python › examples › find-ascii-value-of-character
Python Program to Find ASCII Value of Character | Vultr Docs
December 5, 2024 - Start by choosing a character whose ASCII value you need. Use Python's built-in ord() function to obtain the ASCII value.
🌐
Real Python
realpython.com › ref › builtin-functions › ascii
ascii() | Python’s Built-in Functions – Real Python
The built-in ascii() function returns a string containing a printable representation of an object, with non-ASCII characters escaped using \x, \u, or \U escapes.
🌐
Codecademy
codecademy.com › docs › python › built-in functions › ascii()
Python | Built-in Functions | ascii() | Codecademy
September 3, 2021 - The Python ascii() function receives an object containing string data as input, and returns the object as a printable representation with \x, \u, or \U escapes for non-ASCII characters (accented characters).