What is the purpose of chr() function?

078

The chr() function in Python is used to convert an integer (representing a Unicode code point) into its corresponding character. The function takes a single argument, which is the integer value, and returns the string representation of the character.

Example Usage:

# Convert Unicode code point to character
character = chr(97)  # 97 is the Unicode code point for 'a'
print(character)  # Output: 'a'

In this example, chr(97) returns the character 'a', as 97 is the Unicode code point for that character.

0 Comments

no data
Be the first to share your comment!