Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python中print语句的问题_Python_Function_Loops_Turtle Graphics - Fatal编程技术网

python中print语句的问题

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):

在使用turtle模块时,python中的print语句有问题

好的,当我运行f.f.g代码时: 文字“是”和海龟的y坐标会被打印出来,但末尾的“是”不会被打印出来。只有在我关闭turtle屏幕后,才会再次打印“是”以及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()

我需要一些关于发生了什么的信息。非常感谢您提供的所有帮助。

我正在使用Python 3.2.1如果您使用
python3-u运行脚本,该怎么办?我必须下载它吗。这将需要很长时间。您当前如何调用您的程序?
end=“yes\n”
是否工作得更好?输出可能会被缓冲,直到打印换行符。