我對python很陌生,經過大量搜索后無法解決問題?;蛟S你們可以幫幫我。我想向 1 個butten 添加多個命令。所以如果你有 100hp,你每次都會輸 10hp,如果你是 0hp,你會得到 50hp,但不知道怎么做。我讀過你需要使用 1 個函數并且在這兩個函數中,但是當我這樣做時,我得到一個錯誤。player_1_lose_10_Button = Button(self, text = "10 HP", command=self.myfunction) player_1_lose_10_Button.place(x=180,y=140)def myfunction(self): lose10(self) check(self)def check(self): global player1health if player1health <= 0: player1health +=50 player_1_lose_10_Button = Button(self, text = "50 HP", command=self.check) print('You died, you get 50hp back')def lose10(self): global player1health player1health-=10 print(f'You lost 10 HP, current HP: {player1health}')
添加回答
舉報
0/150
提交
取消