获取windows桌面路径

Python 获取windows桌面路径

# -*- coding: utf-8 -*-
"""
@Time    : 2021/7/20 11:34
@Author  : Little Duo
@File    : Tools.py
"""
import winreg


def winDesktopPath():
    """
    获取windows桌面路径
    :return:
    """
    key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
    desktopPath = winreg.QueryValueEx(key, "Desktop")[0]
    return desktopPath
posted @ 2023-02-28 14:34  LittleDuo  阅读(22)  评论(0)    收藏  举报