解决Pycharm调用Turtle时 窗口一闪而过的问题

如下所示:

#彩色螺旋线
import turtle
turtle.pensize(2)
turtle.bgcolor("black")
colors = ["red","yellow","purple","blue"]
turtle.tracer(False)
for x in range(400):
 turtle.forward(2*x)
 turtle.color(colors[x % 4])
 turtle.left(91)
turtle.tracer(True)

在用pycharm调用Turtle画图时,上面的代码显示一闪而过

最后加上一句turtle.done()即可解决

'''
想要学习Python?Python学习交流群:1004391443满足你的需求,资料都已经上传群文件,可以自行下载!
'''
#彩色螺旋线
import turtle
turtle.pensize(2)
turtle.bgcolor("black")
colors = ["red","yellow","purple","blue"]
turtle.tracer(False)
for x in range(400):
 turtle.forward(2*x)
 turtle.color(colors[x % 4])
 turtle.left(91)
turtle.tracer(True)
turtle.done()

效果如下:

猜你喜欢

转载自blog.csdn.net/fei347795790/article/details/89712158