我是Python编程(一般编程)的初学者,只是在Python中使用Turtle模块,并想知道为什么使用乌龟的龟的坐标。当在图形界面中显示时,下面的程序中的pos()总是给出(0,0)移动乌龟后?当用相同的turtle.forward()使用Python shell来移动龟时,情况并非如此?乌龟的位置总是显示(0,0)
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
def draw_lines(w, height):
w.begin_fill()
w.right(90)
w.forward(height)
w.write(turtle.pos())
line = turtle.Turtle()
line.color("blue", "red")
line.pensize(3)
height = [50]
for x in height:
draw_lines(line, x)
wn.mainloop()
谢谢!