开发者

Python Directory Display in Finder, Explorer, Dolphin, etc... (Cross-Platform)

I would like to find some way of Viewing a Directory in the default file system viewer (Windows Explorer, Finder, Dolphin, etc...) tha开发者_JAVA技巧t will work on all major platforms. I do not have the detailed knowledge of Linux, nor of OSX in order to write this. Is there some script out there that will do what I want?


OSX:

os.system('open "%s"' % foldername)

Windows:

os.startfile(foldername)

Unix:

os.system('xdg-open "%s"' % foldername)

Combined:

import os

systems = {
    'nt': os.startfile,
    'posix': lambda foldername: os.system('xdg-open "%s"' % foldername)
    'os2': lambda foldername: os.system('open "%s"' % foldername)
     }

systems.get(os.name, os.startfile)(foldername)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜