python通过注册表准确获得Windows桌面路径(为了一定的通用性)

参考文章:https://blog.csdn.net/u013948858/article/details/75072873

使用python内置的winreg模块,非常方便:

import winreg

key=winreg.OpenKey(winreg.HKEY_CURRENT_USER,r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")

DesktopPath=winreg.QueryValueEx(key,"Desktop")[0]

python通过注册表准确获得Windows桌面路径(为了一定的通用性)

以后要获取其它win系统相关信息时也可首先向注册表方向考虑。

 

上一篇:使用Python删除Windows注册表值


下一篇:Python 获取桌面路径的方法