[英]How to fix Python Turtle Terminator Error?
我正在构建一个小型汽车模拟器游戏。 它就像一个终端 window,我输入 start 并正常启动。 我按下停止它就停止了。 不幸的是,当我再次启动它时,我遇到了这样的错误。
Traceback (most recent call last):
File "C:\Users\****\OneDrive\New folder\Car Emulator.py", line 12, in <module>
turtle.shape('square')
File "<string>", line 5, in shape
turtle.Terminator
我不知道这是什么意思,因为我调用了turtle.bye() function。 尽管我就这样搜索了所有 Stack Overflow 论坛。 代码是这样的:
while True:
command = input(">").lower()
if command == "start":
if engine == False:
engine = True
print("Car started.")
t.shape('square')
else:
restart = input("Car already started. Restart? (Y) Yes (N) No ")
if restart.upper == "Y":
engine = False
t.bye()
engine = True
t.shape('turtle')
print("Car Restarted.")
elif command == "stop":
if engine == True:
engine = False
t.bye()
print("Car stopped.")
else:
print("Car already stopped.")
elif command == "help":
print('''
start - start the car
stop - stop the car
quit - exit
''')
elif command == "quit":
请有人向我解释一下
while True:
command = input(">").lower()
if command == "start":
if engine == False:
engine = True
print("Car started.")
#t.shape('square')
else:
restart = input("Car already started. Restart? (Y) Yes (N) No ")
if restart.upper == "Y":
engine = False
# t.bye()
engine = True
#t.shape('turtle')
print("Car Restarted.")
elif command == "stop":
if engine == True:
engine = False
#t.bye()
print("Car stopped.")
else:
print("Car already stopped.")
elif command == "help":
print('''
start - start the car
stop - stop the car
quit - exit
''')
elif command == "quit":
output
[root@localhost ~]# python3 test.py
>start
Car started.
>stop
Car stopped.
>start
Car started.
>stop
Car stopped.
>stop
Car already stopped.
>start
Car started.
>start
Car already started. Restart? (Y) Yes (N)
检查你的while循环,如果你想在while循环中重复任何东西,它应该有一个正确的缩进。 示例https://www.w3schools.com/python/python_while_loops.asp
注意:删除了部分代码进行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.