In [2]:
import random

def menu():
    print('''=====游戏菜单=====
                1. 成语游戏
                2. 诗词游戏
                3. 退出游戏
             =====游戏菜单=====''')

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

                   .-"      "-.
                  /            \
                 |              |
                 |,  .-.  .-.  ,|
                 | )(__/  \__)( |
                 |/     /\     \|
       (@_       (_     ^^     _)
  _     ) \_______\__|IIIIII|__/__________________________
 (_)@8@8{}<________|-\IIIIII/-|___________________________>
        )_/        \          /
       (@           `--------`
       
       
       
          ======YOU LOSE=======
        '''
    )
    return
    
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 idiom_robot(file_name):
    with open(file_name) as fh:
        text = fh.read()
    idioms = text.split()
    idiom = random.choice(idioms)
    chs = get_ch_table(text.replace(r'\n', ''))

    guess_ch_table = [ch for ch in idiom]
    while len(guess_ch_table) < 6:
        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,6,2):
        print(guess_ch_table[i], guess_ch_table[i+1])
    
    return idiom
def  poem_sentence_robot(file_name):
    with open(file_name) as fh:
        text = fh.read()
    poems = text.spilt()
    poem = radom.choice(poems)
    chs = get_ch_table(text.replace(r'\n',''))
    guess_ch_table = [ch for ch in poem]
    while len(guess_ch_table) < 7:
        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,7,2):
        print(guess_ch_table[i], guess_ch_table[i+1])
    
    return poem

def main1():
    filename = r'K:\temp\idioms_correct.txt'
    score = 10
    while score >= 0:
        real_idiom = idiom_robot(filename)
        answer_idiom = input('请输入猜测成语,回车结束,直接回车表示退出游戏:')
        if answer_idiom == real_idiom:
            print('答对了,加十分')
            score += 10
            print('你当前的分数是:', score)
            if score == 100:
                win()
                return
        elif answer_idiom == '':
            print('退出游戏。')
            print('你最后的分数是:', score)
            return
        else:
            score -= 10
            print('答错了,减十分')
            print('成语其实是:', real_idiom)
            print('你当前的分数是:', score)
    else:
        lose()
        return
def main2():
    file_name = r'K\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
    
if __name__ == '__main1())__':
    main1()
else:
    main2()


  File "<ipython-input-2-40f16011c6d5>", line 33
    return
          ^
IndentationError: unindent does not match any outer indentation level