"""代码除错.py 请去除下列代码中的错误。 from tutrle import * screen = Screen() screen.Setup(800,600) screen.bjcolor("lightgreen") screen.delay(0.1) ta = turtle() ta.shape("tutlre") ta.color("darkcyan") ta.width("4") print = 0 while counter < 20 for i in ranger(4): for i in ranger(10): ta.fd(15) ta.left(9) ta.stamp ta.right(180) ta.rt(18) print = print +1 print(print) Screen.mainloop()
下面指出了错误
"""代码除错.py 请去除下列代码中的错误。 """" # 多了一双引号 from tutrle import * # 类名错误 screen = Screen() # 小括号错误 screen.Setup(800,600) screen.bjcolor("lightgreen") # 方法名错误 screen.delay(0.1) ta = turtle() # 类名错误 ta.shape("tutlre") # 没有这个形状 ta.color("darkcyan") ta.width("4") print = 0 # 用常见命令做变量名 while counter < 20 # 没有冒号 for i in ranger(4): # 应该是range for i in ranger(10): # 应该是range ta.fd(15) ta.left(9) # 缩进错误 ta.stamp # 忘了小括号(不会报错) ta.right(180) ta.rt(18) print = print +1 print(print) # 由于print被重定义,此处报错 Screen.mainloop() # 应该是screen.mainloop()