简体   繁体   English

Finder,Explorer,Dolphin等中的Python目录显示...(跨平台)

[英]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...) that will work on all major platforms. 我想找到一些在默认文件系统查看器(Windows资源管理器,Finder,Dolphin等)中查看目录的方法,该方法适用于所有主要平台。 I do not have the detailed knowledge of Linux, nor of OSX in order to write this. 我没有Linux的详细知识,也没有OSX的详细知识。 Is there some script out there that will do what I want? 那里有一些脚本会做我想要的吗?

OSX: OSX:

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

Windows: 视窗:

os.startfile(foldername)

Unix: 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM