在Linux中打开文件夹窗口的标准方法? [英] Standard way to open a folder window in linux?
问题描述
我想在适当的文件管理器中,从跨平台(windows/mac/linux)Python应用程序中打开一个文件夹窗口.
I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.
在OSX上,我可以使用以下方法在查找器中打开一个窗口
On OSX, I can open a window in the finder with
os.system('open "%s"' % foldername)
,在Windows上,
and on Windows with
os.startfile(foldername)
unix/linux呢?有标准的方法吗?还是我必须对gnome/kde/etc进行特殊处理并手动运行相应的应用程序(nautilus/konqueror/etc)?
What about unix/linux? Is there a standard way to do this or do I have to special case gnome/kde/etc and manually run the appropriate application (nautilus/konqueror/etc)?
看起来可以由 freedesktop.org 人们指定的内容(类似于webbrowser
的python模块,也很好!).
This looks like something that could be specified by the freedesktop.org folks (a python module, similar to webbrowser
, would also be nice!).
推荐答案
os.system('xdg-open "%s"' % foldername)
xdg-open
也可以用于文件/URL
xdg-open
can be used for files/urls also
这篇关于在Linux中打开文件夹窗口的标准方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!