在很多时候需要获取某些字母的ASCII值或者是已知ASCII值想要知道对应的字符是什么,其中python中有两个函数分别是ord/chr函数可以实现ASCII值与字符之间的切换。ord函数可以获取一个字母的ascii值,chr函数可以将ascii值转换为字符
if __name__ == '__main__':
print(ord("a"))
print(ord("A"))
print(chr(97))
print(chr(66))
在很多时候需要获取某些字母的ASCII值或者是已知ASCII值想要知道对应的字符是什么,其中python中有两个函数分别是ord/chr函数可以实现ASCII值与字符之间的切换。ord函数可以获取一个字母的ascii值,chr函数可以将ascii值转换为字符
if __name__ == '__main__':
print(ord("a"))
print(ord("A"))
print(chr(97))
print(chr(66))