关注我的 previous问题,如何导入与导入它的文件处于同一级别的文件夹中的模块?我需要进入我的模型文件夹,但无法导入它:
$ python generate_test_data.py
Traceback (most recent call last):
File "generate_test_data.py", line 6, in <module>
from models import *
ImportError: No module named models
Exception KeyError: KeyError(48562256,) in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored
我的项目结构是这样的:
/
- generate_test_data.py
- app/
-- __init__.py
-- models.py
请您参考如下方法:
from app.models import *
应该可以解决问题
