# 使用背景:

  需要对字符进行转换时使用 其中ord函数可以将字符转化为你所需要的ASCII码,chr函数可以将0-255中的任一整数

  转化为你所需要的字符。通过这样的转化 你可以方便的完成字符与数字之间的转换操作,更好使用for循环以及if判断

  等常用操作。

# 代码:

# coding=utf-8
"""
测试 ord函数 和 chr函数
"""

print(ord("x"))
print(ord("a"))

print(chr(97))
print(chr(98))

Python 中的 ord() 函数和 chr()函数

 

相关文章:

  • 2022-12-23
  • 2021-08-16
  • 2022-02-03
  • 2022-12-23
  • 2021-11-15
  • 2021-07-21
  • 2021-12-13
  • 2021-05-26
猜你喜欢
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案