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

标签 python python-3.x geometry turtle-graphics

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

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()

关于python - 如何在 Python 3 中使用 Turtle 绘制圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46695126/

相关文章:

python - 什么时候用 C 重写 Python 模块有意义?

python - 如何通过他们的唯一 ID 获取 Gearman Jobs 的状态?

python - python中的类,如何设置属性

python - PyQt5 不将设置保存到 ini 文件

java - 用java创建三角形 slider

matlab - PrincipalAxisLength 测量值是否等于 regionprops3 输出中的对象直径?

python - 为什么内置 sum 在 "from numpy import *"之后表现错误?

python-3.x - Python 3.5 类变量

python-3.x - Python 3 http.server - 一个奇怪的IP地址试图连接我的服务器

geometry - KonvaJS 连接正方形并正确放置线条?