In [1]:
import random

def welcome():
    print(
        '''
           ======欢迎来到游戏=======
        '''
    )


def mune():
    print('''             =====游戏菜单=====
                1. 游戏说明
                2. 成语游戏
                3. 诗词游戏
                4. 退出游戏
                5. 制作团队
             =====游戏菜单=====''')
    
def show_instruction():
    print ('猜诗词游戏\n')
    
def win():
    print(
        '''
           ======恭喜你,你赢了=======
        
    
                ."".    ."",
                |  |   /  /
                |  |  /  /
                |  | /  /
                |  |/  ;-._ 
                }  ` _/  / ;
                |  /` ) /  /
                | /  /_/\_/\
                |/  /      |
                (  ' \ '-  |
                 \    `.  /
                  |      |
                  |      |
          
          ======恭喜你,你赢了=======
        '''
    )
    
    
def lose():
    print(
        '''
           ======YOU LOSE=======
        
    
                

                   .-"      "-.
                  /            \
                 |              |
                 |,  .-.  .-.  ,|
                 | )(__/  \__)( |
                 |/     /\     \|
       (@_       (_     ^^     _)
  _     ) \_______\__|IIIIII|__/__________________________
 (_)@8@8{}<________|-\IIIIII/-|___________________________>
        )_/        \          /
       (@           `--------`
       
       
       
          ======YOU LOSE=======
        '''
    )
    

def game_over():   #次数用完计算机仍然没有猜出来
    print(
        '''
           ======GAME OVER=======
        
             _________ 
            / ======= \ 
           / __________\ 
          | ___________ | 
          | | -       | | 
          | |         | | 
          | |_________| |________________ 
          \=____________/                ) 
          / """"""""""" \               / 
         / ::::::::::::: \          =D-' 
        (_________________) 

       
          ======GAME OVER=======
        '''
    )
    

def get_ch_table(line):
    ch_table = []
    for ch in line:
        if ch not in ch_table:
            ch_table.append(ch)
    return ch_table

    
def poem_robot(filename):  
    with open(filename) as fh:
        text = fh.read()
    poems = text.split()
    poem = random.choice(poems)
    chs = get_ch_table(text.replace(r'\n', ''))
        
    guess_ch_table = [ch for ch in poem]
    while len(guess_ch_table) < 12:
        ch = random.choice(chs)
        if ch not in guess_ch_table:
            guess_ch_table.append(ch)
    
    random.shuffle(guess_ch_table)
    
    for i in range(0,12,3):
        print(guess_ch_table[i], guess_ch_table[i+1],guess_ch_table[i+2])
    return poem

    
def guess_idiom_game():
    print ('hahaha\n')   

def guess_poem_game():
    filename = 'f:\python\poems_correct.txt'
    score = 0
    guessted_table = []
    while score >= 0:
        guess_poem = poem_robot(filename)
        answer_poem = input('请输入猜测诗词,回车结束,直接回车表示退出游戏:')
        if answer_poem == guess_poem:
            guessted_table.append(answer_poem)
            print('答对了,加十分')
            score += 10
            print('你当前的分数是:', score)    #添加已猜测和已删除的
            print ()
            if score == 100:
                win()
                return
        elif answer_poem == '':
            print('退出游戏。')
            print('你最后的分数是:', score)
            return
        else:
            score -= 10
            print('答错了,减十分')
            print('诗词其实是:', guess_poem)
            print('你当前的分数是:', score)
            print ()
    else:
        lose()
        return
        
            
        

def main():
    print ('here!')
    welcome()
    while True:
        mune()
        choice = int(input('请输入你的选择:'))
        if choice == 1:
            show_instruction()
        elif choice == 2:
            guess_idiom_game()
        elif choice == 3:
            guess_poem_game()
        elif choice == 4:
            game_over()
            break
        else:
            show_team()
        
    
main()


here!

           ======欢迎来到游戏=======
        
             =====游戏菜单=====
                1. 游戏说明
                2. 成语游戏
                3. 诗词游戏
                4. 退出游戏
                5. 制作团队
             =====游戏菜单=====
请输入你的选择:3
在 高 怜
难 层 青
缘 身 尽
最 喜 自
请输入猜测诗词,回车结束,直接回车表示退出游戏:自缘身在最高层
答对了,加十分
你当前的分数是: 10

乔 春 将
人 锁 东
深 铜 是
二 雀 边
请输入猜测诗词,回车结束,直接回车表示退出游戏:铜雀春深锁二乔
答对了,加十分
你当前的分数是: 20

山 层 各
雨 夜 巴
亡 声 淮
池 涨 秋
请输入猜测诗词,回车结束,直接回车表示退出游戏:
退出游戏。
你最后的分数是: 20
             =====游戏菜单=====
                1. 游戏说明
                2. 成语游戏
                3. 诗词游戏
                4. 退出游戏
                5. 制作团队
             =====游戏菜单=====
请输入你的选择:4

           ======GAME OVER=======
        
             _________ 
            / ======= \ 
           / __________\ 
          | ___________ | 
          | | -       | | 
          | |         | | 
          | |_________| |________________ 
          \=____________/                ) 
          / """"""""""" \               / 
         / ::::::::::::: \          =D-' 
        (_________________) 

       
          ======GAME OVER=======