问题描述
我正在尝试使用Python 3.1找出系统文件夹的位置.例如我的文档" ="C:\ Documents and Settings \ User \ My Documents",程序文件" ="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 Settings\User\My 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中查找系统文件夹位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!