python -25-字符翻译程序

2018-04-19  本文已影响0人  hsiaojun
# coding=utf-8
# 字符对应的字典
char_dict = {"1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", "8": "*", "9": "(", "0": ")"}
while True:
    cmd = input("请输入命令:")
    # 如果输入的是"0123456789"中的数字才执行
    if cmd in "0123456789" and len(cmd) == 1:
        print("键盘中%s号键对应的符号是%s" % (cmd, char_dict[cmd]))
    elif cmd == "quit":
        print("谢谢使用")
        break
    else:
        print("未识别的命令")
上一篇下一篇

猜你喜欢

热点阅读