-
peng111说:
使用python的turtle函数画出任意图形
import turtle turtle.pensize(4) # 设置画笔的大小 turtle.pencolor('red') # 设置画笔颜色 turtle.forward(100) # 向前走100 turtle.right(90) # 向右转90度 turtle.forward(100) # 向前走100 turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.left(120) turtle.forward(100) turtle.left(120) turtle.forward(100) turtle.done() # 结束绘制
效果如下:
-