Python 源代码如下


from turtle import *

def draw9lines(s, cw):
  if s <= 8:
    fd(s)
    return

  for i in range(9):
    draw9lines(s/4, cw if i % 2 == 0 else not cw)
    if i < 8:
      angle = -60 if cw else 60
      if i >= 2 and i <=5:
        angle = -angle
      lt(angle)
  cw = not cw 

setup(startx=0, starty=0)
pu();goto(-256,-200);pd();speed(0)
draw9lines(512, False)

exitonclick()