简单密码(Python)

简单密码

http://www.nowcoder.com/questionTerminal/7960b5038a2142a18e27e4c733855dac

强迫症式的字典 :)

dic = {'a':2, 'd':3, 'g':4, 'j':5, 'm':6, 'p':7, 't':8, 'w':9,
       'b':2, 'e':3, 'h':4, 'k':5, 'n':6, 'q':7, 'u':8, 'x':9,
       'c':2, 'f':3, 'i':4, 'l':5, 'o':6, 'r':7, 'v':8, 'y':9,
                                          's':7,        'z':9}

while True:
    try:
        s, res = input(), ''
        for i in s:
            if i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
                res += 'a' if i == 'Z' else chr(ord(i) + 33)
            elif i in '0123456789':
                res += i
            else:
                res += str(dic.get(i))
        print(res)
    except:
        break
全部评论

相关推荐

点赞 评论 收藏
分享
无敌虾孝子:喜欢爸爸还是喜欢妈妈
点赞 评论 收藏
分享
评论
点赞
3
分享
牛客网
牛客企业服务