猜数字简化版一

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()

  

你可能感兴趣的:(猜数字简化版一)