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]

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

猜你喜欢

转载自www.cnblogs.com/lingchuL/p/11421878.html