新人求助。如何在python turtle graphics上画图
就是画矩形或圆形那些,要用到while语句吗?
pip install turtle
然后输入如下的代码,即可画方画圆
程序代码:
import turtle turtle.ht() # hide turtle turtle.setpos(0,0) turtle.up() turtle.pendown() turtle.forward(40) # start to draw a rectangle turtle.right(90) turtle.forward(40) turtle.right(90) turtle.forward(40) turtle.right(90) turtle.forward(40) turtle.penup() turtle.setpos(80,80) turtle.pendown() turtle.circle(50) # draw a circle turtle.penup() turtle.exitonclick()