python绘制正方形螺旋线的方法
导读:本文共809字符,通常情况下阅读需要3分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 1、 安装turtlePython2安装命令:pipinstallturtulePython3安装命令:pip3installturtle因为turtle库主要是在Python2中使用的,所以安装的时候可能会提示错误:Command"pythonsetup.pyegg_info"failedwitherrorcode12 、利用turtle库... ...
音频解说
目录
(为您整理了一些要点),点击可以直达。1、 安装turtle
Python2安装命令:
pipinstallturtule
Python3安装命令:
pip3installturtle
因为turtle库主要是在Python2中使用的,所以安装的时候可能会提示错误:
Command"pythonsetup.pyegg_info"failedwitherrorcode1
2 、利用turtle库绘制正方形螺旋线
(1)效果图
(2)相关代码
importturtleastt.pen(speed=0)#加快绘图速度t.penup()t.goto(-200,-200)#以左下角某处为起点t.pendown()t.seth(0)length=400while(length!=0):#利用正方形螺旋线的性质来绘图t.fd(length)t.left(90)length-=2.5t.hideturtle()#绘图结束后把海龟头(笔触头)隐藏起来t.done()#绘图结束后使窗口停留
3 、绘图命令介绍
(1)turtle.speed(speed) 画笔绘制的速度范围[0,10]整数。
(2)turtle.goto(x,y) 将画笔移动到坐标为x,y的位置。
(3)turtle.pendown() 动时绘制图形,缺省时也为绘制。
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:
python绘制正方形螺旋线的方法的详细内容,希望对您有所帮助,信息来源于网络。