我用filename创建了自己的模块mymodule.py。该文件包含:
def testmod():
print "test module success"
Run Code Online (Sandbox Code Playgroud)
我已将此文件放在 /Library/Python/2.7/site-packages/mymodule/mymodule.py
我还添加了一个__init__.py文件,这些文件已编译生成
__init__.pyc 和 mymodule.pyc
然后在python控制台中将其导入
import mymodule
哪个很好
当我尝试使用mymodule.testmod()时,出现以下错误:
AttributeError: 'module' object has no attribute 'testmod'
是的,它似乎没有任何功能?