与数字互相转换

基本类型 / 字符类型

# No char type: a char is a 1-char str
char = 'A'
# Code point of the char
int_value = ord(char)
# int_value is 65

char_b = chr(int_value + 1)
# char_b is 'B'

# Any Unicode char, not only ASCII
euro_value = ord('€')
# euro_value is 8364

print(f"{int_value = }")
print(f"{char_b = }")
print(f"{euro_value = }")