【发布时间】:2012-11-15 21:39:19
【问题描述】:
我需要能够向用户询问乌龟命令,例如 forward(90) 并将其作为乌龟命令执行,例如 turtle.forward(90) 并重复直到用户退出。 到目前为止我有:
def turtle_input(prompt):
"""Loop to ask for user input and execute as a turtle command"""
import turtle
while True:
t = input('Enter a turtle command: ')
if t in ['Quit' , 'quit', 'q', 'Q']:
break
turtle.(t)
return prompt
【问题讨论】:
-
除非您使用 python 3,否则您可能需要
raw_input()而不是input()。
标签: python input command turtle-graphics