Python 3.x 运行模块后,我被Python海龟图形所困扰
下面是我根据用户输入绘制多边形的代码。 问题是:我不能输入任何东西。 因为在执行模块之后,海龟图形出现了,它被冻结了。 不确定哪一行是错的Python 3.x 运行模块后,我被Python海龟图形所困扰,python-3.x,Python 3.x,下面是我根据用户输入绘制多边形的代码。 问题是:我不能输入任何东西。 因为在执行模块之后,海龟图形出现了,它被冻结了。 不确定哪一行是错的 import turtle window = turtle.Screen() window.bgcolor('lightblue') turtle = turtle.Turtle() side = int(input("input number of sides")) length = int(input("input length of each side
import turtle
window = turtle.Screen()
window.bgcolor('lightblue')
turtle = turtle.Turtle()
side = int(input("input number of sides"))
length = int(input("input length of each side"))
color = input("input color")
for i in range(side):
turtle.forward(length)
turtle.left(360/side)
turtle.fillcolor(color)
您的脚本工作正常: 这不是一个实现问题。检查您的主机安装 要填充多边形,请使用和
啊,谢谢。我的虚拟机可能有问题。顺便说一句,如何填充多边形内部的颜色?
import turtle
window = turtle.Screen()
window.bgcolor('lightblue')
turtle = turtle.Turtle()
side = int(input("input number of sides"))
length = int(input("input length of each side"))
color = input("input color")
turtle.begin_fill()
for i in range(side):
turtle.forward(length)
turtle.left(360/side)
turtle.fillcolor(color)
turtle.end_fill()