如何在PythonTurtle中获取海龟的位置

问题描述 投票:0回答:1

如果我做了一些随机动作。 我怎样才能得到乌龟回到那里的位置?

我尝试使用一些命令,例如 位置() 乌龟.pos() 但它从未说过 x 和 y 坐标 我使用海龟库 所以我输入 fromturtle import*

python turtle-graphics python-turtle
1个回答
0
投票

您可以使用以下代码来获取海龟的坐标:

turtle.xcor() #For x-coordinate
turtle.ycor() #For y-coordinate
© www.soinside.com 2019 - 2024. All rights reserved.