モジュールのインポートに問題があります。私が使用する場合、
import fruit as f
print f.apple.juice.CALORIES_INT
これは機能します。と
import fruit.apple.juice as j
print j.CALORIES_INT
うまくいきません。投げAttributeError: 'module' object has no attribute 'apple'
ます。それをデバッグする方法について何か提案はありますか?
私のディレクトリ構造は次のようになります。
fruit
--- __init__.py
--- apple
---------__init__.py
--------- juice.py
---------------CALORIES_INT is a variable declared here
--- orange
--------- __init__.py
--------- shake.py
---------------trying to access CALORIES_INT here by importing it.
リンゴはパッケージです。ただし、他のパッケージをインポートできます。