📜  在字母表python代码示例中的位置

📅  最后修改于: 2022-03-11 14:46:06.832000             🧑  作者: Mango

代码示例1
from string import ascii_lowercase
LETTERS = {letter: str(index) for index, letter in enumerate(ascii_lowercase, start=1)} 

def alphabet_position(text):
    text = text.lower()
    numbers = [LETTERS[character] for character in text if character in LETTERS]
    return ' '.join(numbers)