當我運行這段代碼Python的烏龜錯誤 - 從如何看待一個計算機科學家代碼:使用Python學習3
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()
我得到的第一個電話正常工作,比我得到這個錯誤
回溯(最近通話最後一個): 文件 「/home/turte.py」 19行, 在show_poly()
文件 「/home/turte.py」,8號線,在show_poly 苔絲= turtle.Turtle()
文件 「/usr/lib/python3.5/turtle.py」,線3816,在INIT 可見=可見)
文件「/ usr/lib中/python3.5/turtle.py」,線路2557,在初始化 self._update()
文件 「/usr/lib/python3.5/turtle.py」,線2660,在_Update 自我._update_data()
文件「/usr/lib/python3.5/tu rtle.py」,線路2646,在_update_data self.screen._incrementudc()
文件 「/usr/lib/python3.5/turtle.py」,線1292,在_incrementudc
養甲魚的終結者.Terminator
如果我明白了問題,即使關閉了最後一個屏幕,我也無法創建新屏幕。 我運行python 3.5
代碼中引發了'兼容SyntaxError'在這裏。 – Goyo
對不起這是一個縮進錯誤。此外它適用於Python3.4 – Magal