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

时间:2022-09-05 15:08:08

如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
#彩色螺旋线
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()即可解决

?
1
2
3
4
5
6
7
8
9
10
11
12
#彩色螺旋线
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()

效果如下:

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

以上这篇解决pycharm调用turtle时 窗口一闪而过的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/Jamesjjjjj/article/details/80850669