我试图向我女儿展示一些代码,并认为海龟会很有趣。我更喜欢数字,但这对孩子们来说并不有趣。
我在重现文档示例时遇到问题。这更让我烦恼,因为我无法弄清楚。我们还有很多其他事情可以做。
The documentation example (copied below) is supposed to produce this picture. ![Star 1](https://i.stack.imgur.com/A22rG.png)
from turtle import *
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()
该示例不会运行,但我稍微修改了导入和调用以允许它运行。然而,填充的工作方式并不相同。它填充了整个形状 - 不留下那些间隙。这更符合我对有关多边形起点和终点的填充文档的期望。但是,有什么想法吗?
from turtle import *
win = Screen()
t = Turtle()
t.color('red', 'yellow')
t.speed(0)
t.begin_fill()
while True:
t.forward(200)
t.left(170)
if abs(t.pos()) < 1:
break
t.end_fill()
win.exitonclick()
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)