lerrorgk 2017-08-25 10:39 采纳率: 25%
浏览 2175

python中一个画树的函数,能解释一下是怎么运行的吗

其中p = Turtle()
def tree(plist, l, a, f):
""" plist is list of pens
l is length of branch
a is half of the angle between 2 branches
f is factor by which branch is shortened
from level to level."""
if l > 5:
lst = []
for p in plist:
p.forward(l)
q = p.clone()
p.left(a)
q.right(a)
lst.append(p)
lst.append(q)
tree(lst, l * f, a, f)

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-25 15:46
    关注

    递归执行

    plist is list of pens plist是pen的list
    l is length of branch l是分支的长度
    a is half of the angle between 2 branches a是2个分支角度的一般
    f is factor by which branch is shortened f是表示哪个分支被缩减了
    from level to level. 从一层到另一层

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器