Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法让光标(乌龟)移动到画布的右、左、下和上边缘?
有人建议使用turtle.setx()with argument0来移动到最左边的位置。但是当我这样做时,乌龟被移动到默认位置(到中心)。
turtle.setx()
0
使用window_width()和window_height()函数来确定窗口的大小:
window_width()
window_height()
这会将海龟移动到最右边:
import turtle as tt def main(): tt.reset() print(tt.window_width(), tt.window_height()) tt.setx(tt.window_width()//2) if __name__ == '__main__': main() tt.mainloop()