python画正三角形代码 python绘制正三角形_前端

 
#绘制正三角形
import turtle as tl         #导入库turtle,并取别名为tl
tl.color("red")            #设置画笔的颜色
tl.pensize(7)
tl.fillcolor("blue")
tl.begin_fill()
tl.forward(200)             #向正前方爬行200
tl.left(120)                 #左转120度
tl.forward(200)             #向正前方爬行200
tl.left(120)                 #左转120度
tl.forward(200)             #向正前方爬行200
tl.end_fill()