python類的使用與多文件組織


多文件的組織

跨目錄級導入模塊

from ..xxfile import xxmodule    #從上級目錄中的xxfile中導入xxmodule
import xxsub_dir.xxfile    #從xxsub_dir文件夾中導入所有模塊 

執行時的命令

python -m pkg.tests.core_test    #去最頂級執行

(refer) [http://stackoverflow.com/questions/11536764/how-to-fix-attempted-relative-import-in-non-package-even-with-init-py/27876800#27876800]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM