版权声明:本文为业余狙击手原创文章,欢迎阅读,欢迎转载,转载请注明出处,谢谢。 https://blog.csdn.net/sxlsxl119/article/details/84889584
画雪花代码:
import turtle
from turtle import *
def koch(size, n):
if n == 0:
turtle.fd(size)
else:
for angle in [0, 60, -120, 60]:
turtle.left(angle)
koch(size / 3, n - 1)
def main():
turtle.setup(600,600)
turtle.pen(speed = 0, pencolor = 'red')
turtle.penup()
turtle.goto(-200,100)
turtle.pendown()
turtle.pensize(1)
level = 5
koch(400,level)
turtle.right(120)
koch(400, level)
turtle.right(120)
koch(400, level)
turtle.hideturtle()
done()
main()
结果: