打开python软件,CTRL+N新建一个File,在新建的窗口中输入以下两个代码中任意一个
方法一:
#绘制五角星
import turtle
turtle.pensize(5)
turtle.color("yellow","red")
turtle.begin_fill()
count=1
while count<=5:
turtle.forward(100)
turtle.right(144)
count +=1
turtle.end_fill()
方法二:
#FivePointStar.py
from turtle import *
pensize(5)
pencolor('yellow')
fillcolor('red')
begin_fill()
while True:
fd(200)
right(144)
if abs(pos()) <1:
break
end_fill()
摁F5键,等待运行结束,结果如下图所示