mac 上的 python turtle 不工作

标签 python macos turtle-graphics

我正在尝试使用 python 导入 turtle 但出现错误:

Traceback (most recent call last):
  File "turtle.py", line 1, in <module>
    import turtle
  File "/turtle.py", line 32, in <module>
    turtle.pensize(2)
AttributeError: 'module' object has no attribute 'pensize'

python是自带turtle还是需要单独下载?

我的python是2.7.2

最佳答案

你调用了你的文件 turtle.py,所以 import turtle 导入了你的程序,而不是你想要的模块。

重命名您的程序并删除任何 turtle.py[co] 文件。

关于mac 上的 python turtle 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14987099/

相关文章:

python - 如何使用SQLAlchemy设置和获取关系记录?

python - Pycharm 警告变量未被使用

macos - gcc 不想在 mac 上使用 AVX

使用turtle的Python加载器

python - turtle 图形中的 turtle 方向?

Python Tkinter postscript 错误大小导出

Python正则表达式在某一点之前删除所有内容

python - matplotlib 中缺少标签 - 条形图

macos - Docker for mac - 无法 curl 我的容器

macos - 如何通过 Mac 应用程序的 Github 添加 gitignore 文件