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系统相关信息时也可首先向注册表方向考虑。

 

posted @ 2019-08-28 08:51  零楚L  阅读(415)  评论(0编辑  收藏  举报