2017-02-18 35 views
0

當我運行代碼的功能根本就不
工作,這裏的問題代碼,希望能幫到你:Python龜如何在while循環中使用onKey函數?

import turtle 





plinput = 0 
while plinput == 0: 

def OnePlayer(): 
    global plinput 
    plinput = 1 

def TwoPlayers(): 
    global plinput 
    plinput = 1 

def ThreePlayers(): 
    global plinput 
    plinput = 1 

def FourPlayers(): 
    global plinput 
    plinput = 1 

onkey(Oneplayer, "1") 
onkey(TwoPlayers, "2") 
onkey(ThreePlayers, "3") 
onkey(FourPlayers, "4")<br> 





感謝這是非常重要的

+0

只是猜測:也許這是你所有關於你的行縮進!?請提供一個完整且可運行的示例。 http://stackoverflow.com/help/mcve – infotoni91

+0

請解釋此代碼的預期行爲。即,當您運行此代碼時您期望什麼。 –

回答

0

請解釋你想要你的代碼做什麼。此外,在函數啓動的while循環之後會出現縮進錯誤。

while plinput == 0: 

    def OnePlayer(): 
     global plinput 
     plinput = 1 

    def TwoPlayers(): 
     global plinput 
     plinput = 1 

    def ThreePlayers(): 
     global plinput 
     plinput = 1 

    def FourPlayers(): 
     global plinput 
     plinput = 1 

希望這會有所幫助。 :)