Python turtle绘制 国旗—五星红旗
import turtle
import time
turtle.speed(10)
turtle.screensize(canvheight=200,canvwidth=200,bg="cyan")
turtle.up()
turtle.goto(-200,200)
turtle.down()
turtle.fillcolor("red")
turtle.color("red")
turtle.begin_fill()
turtle.forward(480)
turtle.right(90)
turtle.forward(320)
turtle.left(90)
turtle.backward(480)
turtle.right(90)
turtle.backward(320)
turtle.end_fill()
turtle.up()
turtle.forward(64)
turtle.left(90)
turtle.forward(32)
turtle.down()
a=96
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
turtle.begin_fill()
for i in range(1,6):
turtle.forward(a)
turtle.right(144)
turtle.speed(2)
turtle.end_fill()
turtle.up()
turtle.forward(96)
turtle.left(53)
turtle.forward(36)
turtle.down()
a=32
turtle.begin_fill()
for i in range(1,6):
turtle.forward(a)
turtle.right(144)
turtle.speed(5)
turtle.end_fill()
turtle.up()
turtle.right(80)
turtle.forward(42)
turtle.left(55)
a=32
turtle.begin_fill()
for i in range(1,6):
turtle.forward(a)
turtle.right(144)
turtle.speed(5)
turtle.end_fill()
turtle.up()
turtle.right(96)
turtle.forward(32)
a=32
turtle.begin_fill()
for i in range(1,6):
turtle.forward(a)
turtle.right(144)
turtle.speed(5)
turtle.end_fill()
turtle.up()
turtle.right(54)
turtle.forward(45)
turtle.right(30)
a=32
turtle.begin_fill()
for i in range(1,6):
turtle.forward(a)
turtle.right(144)
turtle.speed(2)
turtle.end_fill()
turtle.ht()
time.sleep(2)
运行结果截图: