📜  如何将字符串转换为不同的字母 python 代码示例

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

代码示例2
text = input()

def encrypt(t):
    chars = list(text)
    allowed_characters = list(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.?!")

    for char in chars:
        for i in allowed_characters:
            if char == i:
                chars[chars.index(char)] = allowed_characters.index(i)
    return chars

print(encrypt(text))