1. 程式人生 > >Pycharm呼叫Turtle時 視窗一閃而過

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()即可解決

#彩色螺旋線
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()

效果如下: