import random

PHRASES ={
   "君恩如水向东流,得宠忧移失宠愁。":"莫向尊前奏花落,凉风只在殿西头。",
        "锦里烟尘外,江村***家。":"圆荷浮小叶,细麦落轻花。",
        "应是天仙狂醉,":"乱把白云揉碎。",
        "安得五彩虹,":"驾天作长桥。",
        "对酒当歌,人生几何!":"譬如朝露,去日苦多。",
        "山不厌高,海不厌深。":"周公吐哺,天下归心。"        
        }

# keep going until they hit CTRL-D
try:
    while True:
        snippets = list(PHRASES.keys())
        random.shuffle(snippets)   # random.shuffle()是打乱列表的顺序。

        for snippet in snippets:
            phrase = PHRASES[snippet]
            question, answer =snippet,phrase   # convert()就是上面定义的函数
                        
            print(question)

            input(">")
            print(f"ANSWER: {answer}\n\n")
except EOFError:
    print("\nBye")

运行结果如下: