Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设一个 gimp (PyGIMP) 插件需要访问一些随插件分发的任意图像文件。鉴于用户可以在任何地方安装该集合,插件本身是否可以确定自己的安装路径以用作这些资源(例如图像)的路径前缀?我曾尝试搜索 pdb,但我一定遗漏了一些东西。
与所有 python 代码一样,您可以os.path.realpath(__file__)使用os.path.abspath(sys.argv[0]).
os.path.realpath(__file__)
os.path.abspath(sys.argv[0])
然而:
gimp.directory
gimp.data_directory
gimp.locale_directory
gimp.plug_in_directory
os.path.join(gimp.data_directory,'scripts')