chr() function in Python

The chr() function in Python converts a unicode code point into a string containing the corresponding character.

Built-in Functions Updated 28 Feb 2017 1 min read

Function Name

chr

Function Signature

chr(i)

Return Value

The numeric value of the Unicode character string.

Function Overview

  • The Unicode specification defines the mapping between a character and how it is represented in computer systems using a numeric value. This mapping is called encoding.
  • The numeric value is called a code point. The whole collection of code points is called codespace.
  • The chr() built-in function in Python converts a numeric value or code point into a string containing the character. The mod() function does the opposite of chr(), given a character it returns the code point.

Example

python
# Example Python program that returns the Unicode codepoint of a given

# Unicode character string

value1 = 85

value2 = 1028

character1 = chr(value1)

character2 = chr(value2)

print(character1)

print(character2)

Output

Output
U

Є