Welcome, guest | Sign In | My Account | Store | Cart

You want to get the ASCII number of a character, or you want to get the character given by an ASCII number.

Python, 5 lines
1
2
3
4
5
# Get the ASCII number of a character
number = ord(char)

# Get the character given by an ASCII number
char = chr(number)

For Unicode characters the builtin functions ord() and unichr() can be used.

Created by Hamish Lawson on Sun, 10 Jun 2001 (PSF)
Python recipes (4591)
Hamish Lawson's recipes (6)

Required Modules

  • (none specified)

Other Information and Tasks