【问题标题】:Why this code doesn't print a circle in python using turtle library?为什么这段代码不使用海龟库在 python 中打印一个圆圈?
【发布时间】:2021-06-20 16:42:31
【问题描述】:

我最近开始使用turtle 库,但我不明白为什么执行以下代码时它不打印圆圈:

from turtle import *

color('green')
speed(11)

for i in range(60):
    circle(i * 1.5)
    right(4)

    hideturtle()
    done()

【问题讨论】:

  • 您的意思是将done() 留在循环中吗?
  • @quamrana 天哪,你是对的,非常感谢! ????

标签: python turtle-graphics python-turtle


【解决方案1】:

如果我们将其视为简单的缩进问题,则以下空白清理:

from turtle import *

color('green')
speed('fastest')

for i in range(60):
    circle(i * 1.5)
    right(4)

hideturtle()
done()

运行良好并打印圆圈:

如果您希望打印其他内容,请描述您想要的输出。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    • 2019-05-25
    • 2021-05-29
    相关资源
    最近更新 更多