根据Python documentation,os.startfile有两个参数:path和operation.路径描述得很好并且不言自明,但是对于操作来说,所有这一切都是:
When another operation [(not
'open'
)] is given, it must be a “command verb” that specifies what should be done with the file. Common verbs documented by Microsoft are'print'
and'edit'
(to be used on files) as well as'explore'
and'find'
(to be used on directories).
这意味着存在其他命令动词.还有其他可用的命令动词吗?如果是这样,他们是什么,他们做了什么?
具体来说,我想知道与“打开文件位置”操作相关的命令动词.
解决方法:
由于所有startfile基本上都是来自shell32的call to ShellExecuteW,所以这不是特定于Python的.
Microsoft docs indicate ShellExecute系列函数中可用的操作(“动词”)取决于确切的系统(注册表).根据该页面,“常用动词”是:
>编辑 – 启动编辑器并打开文档进行编辑.
> find – 从指定目录开始搜索.
> open – 启动一个应用程序.如果此文件不是可执行文件,则会启动其关联的应用程序.
> print – 打印文档文件.
> properties – 显示对象的属性.