Mxiaomi

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
def yanse(*args):
    print('\033[5;%s;48m %s \033[0m' % (args))

def menu():
    a = '开始猜数字游戏'
    b = '只有3次机会'
    yanse(31,a.center(40, '#'))
    yanse(31,b.center(42, '#'))

def GN(c):
    def wrapper():
        menu()
        yanse(31,'gogogo....')
        c()
    return wrapper
@GN
def caiquan():
    SJ = random.randint(1,10)
    count = 0
    while count < 3:
        num = input('input you num: ')
        if num.isdigit():
            num = int(num)
            if num > SJ:
                yanse(34,'BIG')
            elif num < SJ:
                yanse(32,'SMALL')
            else:
                yanse(31,'BINGO')
                return

        else:
            print('num is letters')
            count-=1
        count += 1
caiquan()

  

posted on 2018-06-25 22:53  Mxiaomi  阅读(247)  评论(0编辑  收藏  举报