我正在尝试在 test1 = [a,1,x]
test2 = [b,2,y]
编程中使用 first_alpha = [a,b]
number = [1,2]
last_alpha = [x,y]
模块的Pen
功能,但这给了我这个错误:
turtle
答案 0 :(得分:1)
您的代码是正确的:
import turtle
t = turtle.Pen()
命令行会话:
% python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> t = turtle.Pen()
>>> exit()
%
请确保没有自己的名为turtle.py
的文件,因为这会干扰加载Python自己的turtle.py
库的情况:
% touch turtle.py
% python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> t = turtle.Pen()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'turtle' has no attribute 'Pen'
>>>
生成与您收到的相同的“ AttributeError: module 'turtle' has no attribute 'Pen'
”。
答案 1 :(得分:0)