Python 绘制五角星 【初识Python】

版权声明:本文为博主原创文章,转载请附上博文链接! https://blog.csdn.net/weixin_43802738/article/details/86516079

分享一个使用Python绘制的五角星小案例,欢迎留言探讨指正,大佬勿喷,抱拳

下面呈上小代码

代码:
import turtle		#导入turtle库包

turtle.fillcolor("red")			 #填充颜色
turtle.begin_fill()              #开始画,类似起笔

count = 1                        #计时器,用于计录次数

while count <= 5:                #控制绘制次数
    turtle.forward(100)			 #画笔绘制的方向,向前移动指定的距离
    turtle.right(144)			 #向右转144度
    count += 1                   #循环绘制
    
turtle.end_fill()                #完成填充图片的绘制。


效果:

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43802738/article/details/86516079
今日推荐