使用turtle模块时,我在python中遇到print语句问题。
好的,当我运行f.f.g代码时: 单词"是"并打印乌龟的y坐标,但不打印最后的是。只有在我关闭龟屏后才会出现" yes"再次打印以及再次打印的y坐标。代码应该如何工作,即使乌龟屏幕仍然打开,上面提到的所有内容都会被打印出来。
import turtle
def drawSquare(length, turtle):
for i in range(4):
if (i == 0):
print("yes" + str(turtle.ycor()), end = "yes")#Only end with yes after turtle screen is closed.
turtle.forward(length)
if (i == 0):
print(turtle.ycor(), end = "\n\n")#Only prints after turtle screen is closed.
turtle.left(90)
sc = turtle.Screen()
t = turtle.Turtle()
drawSquare(100, t)
sc.exitonclick()
我需要了解一些信息。所有帮助都非常感谢。