import turtle as tl
tl.color('red')
tl.forward(100)
tl.left(90)
tl.forward(100)
tl.left(90)
tl.color('green')
tl.forward(100)
tl.left(90)
tl.forward(100)
这段代码使用Python的turtle模块,首先设置颜色为红色,然后向前移动100个单位并左转90度,重复此过程形成一个正方形。接着改变颜色为绿色,再次绘制一个正方形,展示turtle库的基础绘图功能。
import turtle as tl
tl.color('red')
tl.forward(100)
tl.left(90)
tl.forward(100)
tl.left(90)
tl.color('green')
tl.forward(100)
tl.left(90)
tl.forward(100)
2325

被折叠的 条评论
为什么被折叠?