【发布时间】:2017-10-08 10:51:19
【问题描述】:
当我运行这段代码时
import turtle
import time
def show_poly():
try:
win = turtle.Screen()
tess = turtle.Turtle()
n = int(input("How many sides do you want in your polygon?"))
angle = 360 / n
for i in range(n):
tess.forward(10)
tess.left(angle)
time.sleep(3)
finally:
win.bye()
show_poly()
show_poly()
show_poly()
我得到的第一个电话工作正常而不是我得到这个错误
Traceback(最近一次调用最后一次): 文件“/home/turte.py”,第 19 行, 在 show_poly() 中
文件“/home/turte.py”,第 8 行,在 show_poly 中 tess = turtle.Turtle()
文件“/usr/lib/python3.5/turtle.py”,第 3816 行,在 init 中 可见=可见)
文件“/usr/lib/python3.5/turtle.py”,第 2557 行,在 init 中 self._update()
文件“/usr/lib/python3.5/turtle.py”,第 2660 行,在 _update self._update_data()
文件“/usr/lib/python3.5/turtle.py”,第 2646 行,在 _update_data 中 self.screen._incrementudc()
文件“/usr/lib/python3.5/turtle.py”,第 1292 行,在 _incrementudc
饲养终结者龟.终结者
如果我了解问题所在,即使我关闭了最后一个屏幕,我也无法创建新屏幕。 我运行 python 3.5
【问题讨论】:
-
您的代码在此处引发
SyntaxError。 -
对不起,这是一个缩进错误。此外,它适用于 Python3.4
标签: python python-3.5 turtle-graphics