18

私は次のディレクトリ構造を持っています

foo/
    __init__.py
    settings.py
    bar/
        __init__.py
        myfile.py

myfile.pyには次のものがあります:設定のインポート

次のエラーが発生します:ImportError: No module named settings、なぜですか?settingsどうすればファイルを効果的にインポートできますかmyfile.py

4

2 に答える 2

23

http://docs.python.org/2/tutorial/modules.html#intra-package-referencesから:

from .. import settings

それが役に立てば幸い

于 2013-01-10T02:54:50.710 に答える