与其在main()内执行main(),不如使用while True循环import turtle as t
def main():
while True:
ask = input("F, B, L, R, or EXIT: ")
ask = ask.upper()
if ask == "F":
x = int(input("How much: "))
t.forward(x)
elif ask == "B":
x = int(input("How much: "))
t.backward(x)
elif ask == "L":
x = int(input("How much: "))
t.left(x)
elif ask == "R":
x = int(input("How much: "))
t.right(x)
elif ask == "EXIT":
return
t.showturtle()
main()
但当GUI程序使用命令行来获取值时,它看起来很糟糕。在
但是turtle有{a1}来获取值,您可以将函数分配给按键。在
^{pr2}$
编辑:使用tkintermessagebox显示错误消息import turtle as t
from tkinter import messagebox
d