python 的turtle 简易画图,第一次
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 的turtle 简易画图,第一次相关的知识,希望对你有一定的参考价值。
import turtle
bob = turtle.Turtle()
#画四方形
def square(t,length):
for i in range(4):
t.lt(90)
t.fd(length)
square(bob,200)
#画多边形
def polygon(t,length,n):
for i in range(n):
t.lt(360/n)
t.fd(length)
polygon(bob,50,30)
#画圆形
def circle(t,r):
for i in range(1000):
t.lt(360 / 1000)
t.fd(3.14*2*r/1000)
circle(bob,100)
以上是关于python 的turtle 简易画图,第一次的主要内容,如果未能解决你的问题,请参考以下文章