while True:
    try:
        key_words = input()
        new_key = ''
        lst_alphla = [chr(97+i) for i in range(26)]
        for word in key_words:
            if word.isupper():
                if word =='Z':
                    new_key+='a'
                else:
                    new_key+= str.lower(chr(ord(word)+1))
            elif word.islower():             
                index = lst_alphla.index(word)
                t=int(index/3)
                if t <=4:
                    new_key+=str(2+t)
                elif word in lst_alphla[15:19]:
                    new_key+='7'
                elif word in lst_alphla[19:22]:
                    new_key+='8'
                elif word in lst_alphla[22:26]:
                    new_key+='9'
            else:
                new_key+=str(word)
        print(new_key)
    except:
        break

一些关于大小写的操作:

  1. 判断字母是否大小写: is.upper() is.lower()
  2. 大小写互相转换: str.upper() str.lower()
  3. 判断在数组哪个位置: list.index('word') 4.字母和unicode相互转换: ord('a')=97 chr(97)='A'