Python turtle如何在while循环中使用onKey函数?

时间:2017-02-18 17:58:33

标签: python python-2.7 python-3.x turtle-graphics

当我运行代码时功能根本不起作用 这是问题代码,希望您可以提供帮助:

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>





谢谢它非常重要

1 个答案:

答案 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

希望这会有所帮助。 :)