我试图做一个简单的命理学,但我找不到一种方法,而不是为每个字母创建一个变量,例如a=1 b=2 c=3 d=4...
Letters are nothing more than a representation of numbers by some encoding. Since consecutive letters are representations of consecutive numbers, you could just take the difference between the letter to 'a'
:
def letter_to_number(c):
return ord(c) - ord('a') + 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.