我正处于学习阶段,我有一个问题import
我创建了一个名为 test 的模块,该文件夹包含我的 test.py、setup.py 和 python.exe,在运行 sdist 并安装后,我在 build 和 dist 文件夹中获得了 MANIFEST 文件、build、lib。
现在,我尝试在 IDLE 中使用我的模块并生成以下内容
>>> import test
>>> movies = ["1","2", ["3", "4", ["5", "6"]]]
>>> test.lol ()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
test.lol ()
AttributeError: 'module' object has no attribute 'lol'
这是我得到的错误。什么地方出了错?出了什么问题?由于我是新手,我自己找不到解决方案。
这是我的模块:
def lol():
for each_item in movies:
if isinstance(each_item, list):
for nest in each_item:
print(nest)
else:
print(each_item)
我使用 Windows 7 机器和 Python 3.2