chr(): Integer To Unicode Character Function
chr | |
---|---|
Language | Python |
Category | Function |
Part Of | Built In Functions |
Named Arguments Count | 0 |
Unnamed Arguments Count | 1 |
Official Documentation | chr Function |
1 Description
The Python chr
function will return a string consisting of
the single character which corresponds to the integer passed to the chr
function.
2 Prototype
Below is the function prototype for the chr
function.
chr(x)
3 Arguments
chr Function Arguments | ||||
---|---|---|---|---|
Name | Type | Default Value | Category | Description |
x |
int |
Unnamed argument | The integer you want translated into a unicode character. |
4 Returns
chr Function Returns | |
---|---|
Return Type | Explanation |
String |
The chr function returns a string which consists of a single unicode character. |
5 Examples
5.1 Get a Unicode Character
In the python file below we make a single call to the chr
function to get the
unicode character that corresponds to the integer value 97
.
#!/usr/bin/python3
def main():
print(chr(97))
if __name__ == "__main__":
main()
Now we can run the Python file and observe the string a
being printed to STDOUT.
user-1@vm:~/Documents$ ./chr_example_1.py
a
user-1@vm:~/Documents$
This document was last updated: