退出机制
# -*- coding: utf-8 -*-:
# -*- coding: cp936 -*-:
import random,easygui
secret = random.randint(1,100)
guess = 0
tries = 0
easygui.msgbox("你好,这里有一个是秘密数,从1到100,你有6次机会,你能猜出来吗?")
while guess != secret and tries < 6 :
guess = easygui.integerbox("请在1到100之间选一个数!")
if not guess: break
if guess < secret:
easygui.msgbox("数字太小,请大一点")
elif guess > secret:
easygui.msgbox("数字太大,请小一点")
tries +=1
if guess == secret:
easygui.msgbox("恭喜你,猜对了,你得到了这个秘密数")
else:
easygui.msgbox("次数超限,请你下次再试!")