其他人问了这个问题,但这对我没有帮助。我写了这段代码:
import turtle
import time
s = turtle.Screen()
t = turtle.Turtle()
t.pd()
t.pensize(3)
t.speed(10)
t.circle(100)
time.sleep(2)
turtle.bye()
fq = str(input("What shape is it? - "))
fq = fq.lower()
while fq != "circle":
print("It's not the right shape")
fq = str(input("What shape is it? - "))
fq = fq.lower()
print("Good Job!")
s = turtle.Screen()
h = turtle.Turtle()
t.pd()
t.pensize(3)
t.speed(10)
t.goto(50, 0)
t.goto(50, 50)
t.goto(0, 50)
t.goto(0, 0)
time.sleep(2)
s.bye()
sq = str(input("What shape is it? - "))
sq = sq.lower()
while sq != "square":
print("It's not the right shape")
sq = str(input("What shape is it? - "))
sq = sq.lower()
print("Good Job!")当我到达第二只乌龟时,我遇到了这个问题:
Traceback (most recent call last):
File "C:/Users/סער 07.סער/Desktop/Python/Shapes.py", line 24, in <module>
h = turtle.Turtle()
File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 3813, in __init__
RawTurtle.__init__(self, Turtle._screen,
File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 2557, in __init__
self._update()
File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 2660, in _update
self._update_data()
File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 2646, in _update_data
self.screen._incrementudc()
File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 1292, in _incrementudc
raise Terminator
turtle.Terminator为什么我会有这样的问题?第一个海龟没有问题,但是当它到达第二个海龟时,我得到了上面的错误。
发布于 2019-11-28 00:59:10
在使用bye()两次终止turtle之后,您可以继续使用turtle
turtle.bye()
s.bye()你期望会发生什么?要为下一个问题做好准备,可以使用screen.reset()、screen.clear()、turtle.reset()或turtle.clear()等命令
from turtle import Turtle
turtle = Turtle()
turtle.hideturtle()
turtle.speed('fastest')
turtle.pensize(3)
turtle.penup()
turtle.sety(-100) # center circle on screen
turtle.pendown()
turtle.circle(100)
fq = input("What shape is this? - ").lower()
while fq != 'circle':
print("That's not the right shape.")
fq = input("What shape is this? - ").lower()
print("Good Job!")
turtle.clear()
turtle.penup()
turtle.goto(-25, -25) # center square on screen
turtle.pendown()
for _ in range(4):
turtle.forward(50)
turtle.left(90)
sq = input("What shape is it? - ").lower()
while sq != 'square':
print("That's not the right shape.")
sq = input("What shape is it? - ").lower()
print("Good Job!")https://stackoverflow.com/questions/59074424
复制相似问题