>>> Exception in Tkinter callbackTraceback (most recent call last): File "C:\Users\Maximillian\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:\Python-koding\steinsakspapir.py", line 64, in scissors botwin += 1UnboundLocalError: local variable 'botwin' referenced before assignment- 尝试从其余代码中删除 botwin 和 youwin - 尝试使用 youwin = youwin + 1 def scissors(): bot = random.randint(1,3) user = 3 if user == bot: printfuver = ("Stalemate, booth players choose scissors") printfu = Label(lowerframe, text=printfuver, fg="blue") printfu.pack() if user == 3 and bot == 1: printfuver = ("Rock crushes scissors, bot win! ") printfu = Label(lowerframe, text=printfuver, fg="red") printfu.pack() botwin += 1 if user == 3 and bot == 2: printfuver = ("Scissors cut paper, you win! ") printfu = Label(lowerframe, text=printfuver, fg="green") printfu.pack() youwin += 1只是希望 botwin 在每次运行该函数后增加 1 的值。
添加回答
举报
0/150
提交
取消