当我尝试运行此代码时,ValueError会出现一个暗指该函数的numRandom。我认为 Python 可以将 int 的字符串表示形式传递给int.
import tkinter
import random
window = tkinter.Tk()
window.geometry('600x500')
x = random.randint(1,300)
remainingTime = True
Attempts = 4
def numRamdom():
global Attempts
while Attempts > 0:
numWritten = int(entryWriteNumber.get())
if numWritten > x:
lblClue.configure(text = 'Its a bigger number')
Attempts = Attempts -1
if numWritten < x:
lblClue.configure(text = 'Its a smaller number')
Attempts = Attempts -1
if numWritten == x:
lblClue.configure(text = 'Congratulations ;)')
remainingTime = False
return remainingTime, countdown(0)
if Attempts == 0:
remainingTime = False
return remainingTime, countdown(0), Attempts, gameOver()
entryWriteNumber = tkinter.Entry(window)
entryWriteNumber.grid(column = 0, row = 1, padx = 10, pady = 10)
numRamdom()
window.mainloop()
qq_遁去的一_1
一只萌萌小番薯
相关分类