In [2]:
import random

def menu():
    print('=====游戏菜单=====')
    print('1. 游戏说明')
    print('2. 开始游戏')
    print('3. 退出游戏')
    print('4. 制作团队')
    print('=====游戏菜单=====')


def win():
    print(
        '''
           ======恭喜你,你赢了=======
        
    
                ."".    ."",
                |  |   /  /
                |  |  /  /
                |  | /  /
                |  |/  ;-._ 
                }  ` _/  / ;
                |  /` ) /  /
                | /  /_/\_/\
                |/  /      |
                (  ' \ '-  |
                 \    `.  /
                  |      |
                  |      |
          
          ======恭喜你,你赢了=======
        '''
    )
    
def lose():
    print(
        '''
           ======YOU LOSE=======
        
    
                

                   .-"      "-.
                  /            \
                 |              |
                 |,  .-.  .-.  ,|
                 | )(__/  \__)( |
                 |/     /\     \|
       (@_       (_     ^^     _)
  _     ) \_______\__|IIIIII|__/__________________________
 (_)@8@8{}<________|-\IIIIII/-|___________________________>
        )_/        \          /
       (@           `--------`
       
       
       
          ======YOU LOSE=======
        '''
    )
    
def game_over():
    print(
        '''
           ======GAME OVER=======
        
             _________ 
            / ======= \ 
           / __________\ 
          | ___________ | 
          | | -       | | 
          | |         | | 
          | |_________| |________________ 
          \=____________/                ) 
          / """"""""""" \               / 
         / ::::::::::::: \          =D-' 
        (_________________) 

       
          ======GAME OVER=======
        '''
    )
    
def show_team():
    print("制作团队:ffffff")
    
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(file_name):
    with open(file_name) 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 game1():
    print('点字成语')
    
def game2():
    filename = r'd:\temp\poems_correct.txt'
    score = 10
    while score >= 0:
        real_poem = poem_robot(filename)
        answer_poem = input('请输入猜测诗词,回车结束,直接回车表示退出游戏:')
        if answer_poem == real_poem:
            print('答对了,加十分')
            score += 10
            print('你当前的分数是:', score)
            if score == 100:
                win()
                return
        elif answer_poem == '':
            print('退出游戏。')
            print('你最后的分数是:', score)
            return
        else:
            score -= 10
            print('答错了,减十分')
            print('成语其实是:', real_poem)
            print('你当前的分数是:', score)
    else:
        lose()
        return
def main():
    choice=int (input('请输入你的选择'))
    if choice== 1:
        game1()
    elif choice==2:
        game2()
    elif choice==3:
        gameover()
        
main()


请输入你的选择2
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-2cf9866642c8> in <module>()
    144         gameover()
    145 
--> 146 main()

<ipython-input-2-2cf9866642c8> in main()
    140         game1()
    141     elif choice==2:
--> 142         game2()
    143     elif choice==3:
    144         gameover()

<ipython-input-2-2cf9866642c8> in game2()
    114     score = 10
    115     while score >= 0:
--> 116         real_poem = poem_robot(filename)
    117         answer_poem = input('请输入猜测诗词,回车结束,直接回车表示退出游戏:')
    118         if answer_poem == real_poem:

<ipython-input-2-2cf9866642c8> in poem_robot(file_name)
     93 
     94 def poem_robot(file_name):
---> 95     with open(file_name) as fh:
     96         text = fh.read()
     97     poems = text.split()

FileNotFoundError: [Errno 2] No such file or directory: 'd:\\temp\\poems_correct.txt'

In [ ]: