python-3.x - 在 IPython (Py 3.4) 笔记本中使用 turtle

标签 python-3.x graphics ipython turtle-graphics

我遵循此处的前几行说明,https://docs.python.org/3.4/library/turtle.html ,这导致了这部杰作:

import turtle
turtle.forward(15)

然而,在Python turtle 图形窗口出现后(中间有小箭头),内核立即死掉。我需要添加什么?

我看到一个视频,其中添加了 t=turtle.pen(),但它会导致相同的结果。

最佳答案

我在 IDLE3 中测试了你的两行代码,以及 Ubuntu 下的普通 python3 提示符,它可以工作...... turtle.forward(15) 打开一个窗口并创建一只 turtle ,然后将其向前移动 15 像素。

为了帮助您弄清楚这一点,这里是我运行的交互式 session ,它以更多步骤执行操作。也许这对你有用(在这种情况下,你在你的 Python 版本或 turtle 图形中遇到了错误),如果没有,至少你会知道“内核死亡”到底在哪里(无论你的意思是什么,确切地说) )。

$ python3
Python 3.4.3 (default, Jul 28 2015, 18:24:59) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> win = turtle.Screen()
>>> t = turtle.Turtle()
>>> t.fd(15)
>>> 

关于python-3.x - 在 IPython (Py 3.4) 笔记本中使用 turtle ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33162252/

相关文章:

python - 使用 'requests-html'时如何使用绝对链接路径获取原始html

ios - 如何将 UIImage 切成碎片(如披萨)并将每个碎片保存在数组中?

java - 平滑绘图算法 (Java2d)

python-3.x - python并行读取csv文件并连接数据框

python - 如何比较具有相同索引的两行并根据特定条件删除一行?

python - 从 iPython 运行 ga.read_ga 的问题

python - 如何使用 IPython %lprun 魔术函数分析类方法

Docker `CMD a b c` VS `CMD ["a", "b", "c"]`

python - 在 Tweepy 中标记时获取推文

java - 从 main 方法传递一个字符串以在同一类文件中进行绘制