python中print语句的问题
在使用turtle模块时,python中的print语句有问题 好的,当我运行f.f.g代码时: 文字“是”和海龟的y坐标会被打印出来,但末尾的“是”不会被打印出来。只有在我关闭turtle屏幕后,才会再次打印“是”以及y坐标。代码的工作原理是,即使海龟屏幕仍然打开,也会打印上面提到的所有内容python中print语句的问题,python,function,loops,turtle-graphics,Python,Function,Loops,Turtle Graphics,在使用turtle模块时,python中的print语句有问题 好的,当我运行f.f.g代码时: 文字“是”和海龟的y坐标会被打印出来,但末尾的“是”不会被打印出来。只有在我关闭turtle屏幕后,才会再次打印“是”以及y坐标。代码的工作原理是,即使海龟屏幕仍然打开,也会打印上面提到的所有内容 import turtle def drawSquare(length, turtle): for i in range(4): if (i == 0):
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()
我需要一些关于发生了什么的信息。非常感谢您提供的所有帮助。我正在使用Python 3.2.1如果您使用
python3-u运行脚本,该怎么办?我必须下载它吗。这将需要很长时间。您当前如何调用您的程序?end=“yes\n”
是否工作得更好?输出可能会被缓冲,直到打印换行符。