python中chr函数_chr()函数以及Python中的示例

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函数

  • 11
    点赞
  • 54
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值