python中chr函数
Python chr()函数 (Python chr() function)
chr() function is a library function in Python, it is used to get character value from the given ASCII code (integer value), it accepts a number (that should be an ASCII code) and returns the character.
chr()函数是Python中的一个库函数,用于从给定的ASCII码 (整数值)中获取字符值,它接受一个数字(应为ASCII码 )并返回字符。
Syntax:
句法:
chr(number)
Parameter:number – an ASCII code (integer value) whose character value we want.
参数: number –我们想要其字符值的ASCII码(整数值)。
Return value: str – returns character (string) value.
返回值: str –返回字符(字符串)值。
Example:
例:
Input:
num = 65
print(chr(num))
Output:
A
Python code to find character value from given ASCII code
Python代码从给定的ASCII代码中查找字符值
# python code to demonstrate an example
# of chr() function
# number (ASCII code of A)
num = 65
print("character value of ", num, " is = ", chr(num))
num = 120
print("character value of ", num, " is = ", chr(num))
num = 190
print("character value of ", num, " is = ", chr(num))
Output
输出量
character value of 65 is = A
character value of 120 is = x
character value of 190 is = ¾
翻译自: https://www.includehelp.com/python/chr-function-with-example.aspx
python中chr函数