第一种:

import winreg
def get_desktop():
    key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
                          r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders',)
    return winreg.QueryValueEx(key, "Desktop")[0]

print(get_desktop())

第二种:

#该方法在用户改变了桌面路径后,会失效
import os
def GetDesktopPath():
    return os.path.join(os.path.expanduser("~"), 'Desktop')

 

相关文章:

  • 2021-10-22
  • 2021-10-17
  • 2021-12-21
  • 2021-12-13
  • 2022-02-06
  • 2021-12-04
  • 2022-12-23
  • 2021-05-20
猜你喜欢
  • 2022-01-23
  • 2022-12-23
  • 2022-02-07
  • 2022-02-28
  • 2021-05-17
相关资源
相似解决方案