程序不应该是顺序执行的吗?在如下代码中,不明白为什么不是先打出count的值,而是直接调用easygui的integerbox。
import random as r
import easygui as g
# 生成随机数
hnum = r.randint(1,10)
'''
def judge_type(temp):
while not(temp.isdigital()):
temp = input('The number you input is wrong,try again!!!')
'''
# 就像堆积木一样,可以调用简单的图形化窗口,但是如果涉及其中的值的传递便瞎了。
input = g.integerbox('Input the number that is in my heart(1-10):',\
title = 'wordGameGUI',lowerbound = 1,upperbound = 10)
count = 1
while 1:
#测试代码区域。
print(count)
if count > 3:
g.msgbox('Time out!!!')
break
if hnum != input:
if hnum > input:
g.msgbox('Small!!!')
input = g.integerbox('Input the number that is in my heart(1-10):',\
title = 'wordGameGUI',lowerbound = 1,upperbound = 10)
else:
g.msgbox('Bigger!!!')
input = g.integerbox('Input the number that is in my heart(1-10):',\
title = 'wordGameGUI',lowerbound = 1,upperbound = 10)
else:
g.msgbox('You are right!!')
break
count += 1
在我执行的多次结果中,总是先执行EasyGUI的模块,然后再打印出count的值。这个顺序不太明白。