The ord/chr function in python realizes the switch between ASCII value and character

In many cases, you need to get the ASCII value of certain letters or the known ASCII value to know what the corresponding character is. Among them, there are two functions in python, the ord/chr function, which can switch between the ASCII value and the character. The ord function can get the ascii value of a letter, and the chr function can convert the ascii value to a character

if __name__ == '__main__':
    print(ord("a"))
    print(ord("A"))

    print(chr(97))
    print(chr(66))

 

Guess you like

Origin blog.csdn.net/qq_39445165/article/details/115146877