Python built-in Method - chr()
The chr()
method is a built-in function in Python that returns a string representing a character whose Unicode code point is the integer passed as an argument.
Here is the syntax for chr()
method:
chr(integer)
where integer
is an integer representing a Unicode code point.
Here are some examples of how to use chr()
:
print(chr(65)) # Output: 'A' print(chr(8364)) # Output: '€'
In the first example, the integer 65
is passed as an argument to chr()
, which returns the string 'A'
. This is because 'A'
has a Unicode code point of 65.
In the second example, the integer 8364
is passed as an argument to chr()
, which returns the string '€'
. This is because '€'
has a Unicode code point of 8364.
The chr()
method is useful for working with Unicode characters, which are represented as integers in Python. By passing an integer representing a Unicode code point to chr()
, you can get a string representation of the corresponding character. This can be useful when dealing with text processing, internationalization, or other applications where you need to manipulate Unicode data.