![]() |
VOOZH | about |
chr() function returns a string representing a character whose Unicode code point is the integer specified.
ASCII Value of 97 is: a
chr(num)
Return: Returns str
chr() function in Python is very easy to use, chr() returns string with a Unicode code equal to the integer specified. Let's look at example for better understanding.
E
Here, we are going to use Python chr() methods to get the string of Unicode.
In this example, we are printing Geeks for Geeks with the chr() in Python.
G e e k s f o r G e e k s
In this example, we are Printing characters for each Unicode integer in the numbers list.
Character of ASCII value 17 is Character of ASCII value 38 is & Character of ASCII value 79 is O
In this example, we are printing Euro with the chr() in Python.
€
In this example, we are printing smiley with the chr() in Python.
????
In this example, we are generating a sequence of integers from 0 to 255.
['\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\t', '\n', '\x0b', '\x0c', '\r', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19...
Output :
No Output
We won't get any output and the compiler will throw an error:
Hangup (SIGHUP)
Traceback (most recent call last):
File "Solution.py", line 7, in <module>
print(chr(-400))
ValueError: chr() arg not in range(0x110000)
In this article we discussed the working, uses and examples of Python chr() function. chr() function is very easy and fun to use. It is very useful when working with Unicode encoded data.
Hope you learnt about Python chr() with different examples