参考 https://zhuanlan.zhihu.com/p/53930960
同级包的引用:
import sys, os
base_path = os.path.dirname(os.path.dirname(
os.path.abspath(__file__)))
sys.path.append(base_path)
---------------- sys拼接 一定要在自定义包引入之前定义 ----------------------------------
import package.test1 as test1 注意import的顺序。
print(test1.a)
最后
以上就是温柔保温杯最近收集整理的关于python 不同目录包的互相引用的全部内容,更多相关python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复