该函数在选择一个整数后不会停止,它会在无限循环中继续执行。任何人都可以告诉我为什么,或者我该如何修复这个问题?随机int无限循环
def wGen():
top = len(Repo.words)
randInt = random.randint(0,len(Repo.words))
print randInt, top
它产生这样的输出:(1037元数据库中的数)
...
214 1037
731 1037
46 1037
490 1037
447 1037
103 1037
342 1037
547 1037
565 1037
90 1037
...
你去那里我调用函数与此“菜单一样功能”
def gameMenu():
"""Game Menu"""
gameMenuPrint()
def m():
inp = raw_input('enter option: ')
while inp != 'q':
if inp == 'play' or inp =='1': GameC.wGen()
elif inp == 'help' or inp =='2': pass
elif inp == 'back' or inp =='0': mainMenu()
else:
print 'wrong input!'
inp = raw_input('enter valid a option!: ')
m()
你可以显示调用代码吗? – 2012-02-05 01:23:06
你给的作品适合我。问题在别的地方。 – a3nm 2012-02-05 01:24:49
我使用调用函数的代码编辑我的帖子。这是你的意思吗? – 2012-02-05 01:37:49