在 Python 中查找系统文件夹位置 [英] Find system folder locations in Python
问题描述
我正在尝试使用 Python 3.1 找出系统文件夹的位置.例如我的文档"=C:Documents and SettingsUserMy Documents"、Program Files"=C:Program Files"等
I am trying to find out the location of system folders with Python 3.1. For example "My Documents" = "C:Documents and SettingsUserMy Documents", "Program Files" = "C:Program Files" etc etc.
推荐答案
我发现 一种稍微不同的做法.这种方式将为您提供各种系统文件夹的位置,并使用真实的单词而不是 CLSID.
I found a slightly different way of doing it. This way will give you the location of various system folders and uses real words instead of CLSIDs.
import win32com.client
objShell = win32com.client.Dispatch("WScript.Shell")
allUserDocs = objShell.SpecialFolders("AllUsersDesktop")
print allUserDocs
其他可用文件夹:AllUsersDesktop、AllUsersStartMenu、AllUsersPrograms、AllUsersStartup、桌面、收藏夹、字体、MyDocuments、NetHood、PrintHood、Recent、SendTo、StartMenu、Startup &模板
Other available folders: AllUsersDesktop, AllUsersStartMenu, AllUsersPrograms, AllUsersStartup, Desktop, Favorites, Fonts, MyDocuments, NetHood, PrintHood, Recent, SendTo, StartMenu, Startup & Templates
这篇关于在 Python 中查找系统文件夹位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!