使用 PyCharm 绘制乌龟(python) [英] Drawing with turtle(python) using PyCharm
本文介绍了使用 PyCharm 绘制乌龟(python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行最新的 PyCharm Pro 版本并尝试从一个草稿文件运行以下代码,但它似乎不起作用
I'm running the latest PyCharm Pro version and trying to run the below code from a scratch file but it doesn't seem to work
import turtle
wn = turtle.Screen()
alex = turtle.Turtle()
alex.forward(150)
alex.left(90)
alex.forward(75)
不工作我的意思是,没有窗口弹出,但我确实在输出中看到
By not working I mean, no window is popping out however I do see in the output saying
Process finished with exit code 0
任何想法
- 如果可以通过 PyCharm 完成
- 我在配置方面缺少什么
干杯
推荐答案
我设法通过使用以下代码找到了一种方法.
I managed to find out a way of doing it by using the below code.
唯一的缺点是它在完成后会关闭画布.
The only downside is that it does close the canvas once it finished.
def main():
wn = turtle.Screen() # creates a graphics window
alex = turtle.Turtle() # create a turtle named alex
alex.forward(150) # tell alex to move forward by 150 units
alex.left(90) # turn by 90 degrees
alex.forward(75) # complete the second side of a rectangle
if __name__ == "__main__":
main()
如果有人对如何不关闭画布有不同的想法,那就太棒了.
If anyone has a different idea on how to not close the canvas that will be awesome.
谢谢,
丹妮
这篇关于使用 PyCharm 绘制乌龟(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文