# 在 程序文件 中访问资源包里的图片是
../资源包/资源文件1.png
# 在 模块1 程序文件1-1 里访问资源包里的图片是:
../../资源包/资源文件1.png
有没有什么方法能够让他们结合起来?用一个固定式就能直接访问资源包里的图片
能不用绝对路径吗?
把项目文件夹代表的目录加入到python的搜索模块的路径集,具体就是在程序文件xxx中加入类似代码:
import os
import sys
base_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(base_path + "/..")
sys.path.append(base_path + "/../..")