Python 试图找出调用win32com.client.Dispatch的混合结果
我看到了这个帖子 所以我想我要做个实验。有经验的人能解释这些结果吗Python 试图找出调用win32com.client.Dispatch的混合结果,python,python-3.x,Python,Python 3.x,我看到了这个帖子 所以我想我要做个实验。有经验的人能解释这些结果吗 >>> import win32com.client >>> shellobject = win32com.client.Dispatch("Wscript.Shell") >>> print (shellobject.SpecialFolders("ProgramFiles")) >>> print (shellobject.SpecialFolders
>>> import win32com.client
>>> shellobject = win32com.client.Dispatch("Wscript.Shell")
>>> print (shellobject.SpecialFolders("ProgramFiles"))
>>> print (shellobject.SpecialFolders("Common AppData"))
>>> print (shellobject.SpecialFolders("AppData"))
F:\Documents and Settings\Randy1\Application Data
>>> print (shellobject.SpecialFolders("My Music"))
>>> print (shellobject.SpecialFolders("MyMusic"))
>>> print (shellobject.SpecialFolders("AppData"))
F:\Documents and Settings\Randy1\Application Data
根据MSDN
以下特殊文件夹可用:
- 冲积层
- AllUsersStartMenu
- 冲积层程序
- 诱惑启动
- 桌面
- 最爱
- 字体
- 我的文件
- 幽冥
- 印刷厂
- 节目
- 最近的
- 森托
- 开始菜单
- 启动
- 模板
WshShell
对象,它比win32com
更可靠
var shell = new ActiveXObject("WScript.Shell");
WScript.Echo(shell.SpecialFolders("ProgramFiles"));
WScript.Echo(shell.SpecialFolders("AppData"));
shell.SpecialFolders(“ProgramFiles”)
也是一个空字符串。谢谢!我会投票支持你的答案,但我对这个网站太陌生了,我没有权限……在windows中获取此信息的最简单方法似乎是键入shell:SpecialFolderName。我在想这是像那样传递的。你的回答帮助我更好地了解了事情的进展。