Skip to main content
 首页 » 编程设计

python之如何在 Python 3 中使用 Turtle 绘制圆

2025年05月04日14shihaiming

这是我已经拥有的代码,但它说我需要定义我知道我需要的“多边形”,但不确定我一直在尝试的方式和不同的方式总是给我错误。

import turtle 
import math 
 
apple=turtle.Turtle() 
 
def draw_circle(t, r): 
    circumference = 2 * math.pi * r 
    n = 50 
    length = circumference / n 
    polygon(t, n, length) 
 
draw_circle(apple, 15) 
 
turtle.exitonclick() 

请您参考如下方法:

使用圆圈法

import turtle 
import math 
 
apple=turtle.Turtle() 
 
def draw_circle(t, r): 
    turtle.circle(r) 
 
draw_circle(apple, 15) 
 
turtle.exitonclick()