小编Jac*_*hes的帖子

Python:在我自己的模块中找不到任何功能?

我用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__.pycmymodule.pyc

然后在python控制台中将其导入

import mymodule

哪个很好

当我尝试使用mymodule.testmod()时,出现以下错误:

AttributeError: 'module' object has no attribute 'testmod'

是的,它似乎没有任何功能?

python attributes module python-2.7 webapp2

4
推荐指数
1
解决办法
3897
查看次数

标签 统计

attributes ×1

module ×1

python ×1

python-2.7 ×1

webapp2 ×1