我正在浏览pkg_resources
文档(https://setuptools.readthedocs.io/en/latest/pkg_resources.html),并尝试实现类似于resource_filename
的对象,但是我只想要文件所在的资源目录。我是否将此定义为其他地方的默认目录,例如setup.py
中的内容?
此外,如果存在这样的路径对象,与仅使用os.path
对象相比,使用它有什么好处吗?
当无法将资源实际设置为resource_isdir
时,此包如何包含resource_listdir
和dir
之类的方法?
pkg_resources.resource_filename
接受目录作为参数-但是,您必须将包指定为包中的父目录。