How to get the ASCII value of a character

前端 未结 6 493
天命终不由人
天命终不由人 2020-11-22 07:04

How do I get the ASCII value of a character as an int in Python?

6条回答
  •  孤独总比滥情好
    2020-11-22 07:29

    To get the ASCII code of a character, you can use the ord() function.

    Here is an example code:

    value = input("Your value here: ")
    list=[ord(ch) for ch in value]
    print(list)
    

    Output:

    Your value here: qwerty
    [113, 119, 101, 114, 116, 121]
    

提交回复
热议问题