該函數在選擇一個整數後不會停止,它會在無限循環中繼續執行。任何人都可以告訴我爲什麼,或者我該如何修復這個問題?隨機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