os.path.join(os.path.expanduser("~"), 'Desktop')不能获取OneDrive上备份的桌面

最近在测试一个os库的文件管理功能,想在windows电脑的桌面上创建一个测试文件夹,os.path.join(os.path.expanduser("~"), 'Desktop')可以获取系统桌面的路径,但我的电脑上开了OneDrive,把桌面备份到C:\Users\x\OneDrive\Desktop上了,而os返回的是C:\Users\x\Desktop。


desktop_path = os.path.join(os.path.expanduser("~"), 'Desktop')
        print(desktop_path)
        dir_path = desktop_path + "\\" + str(name)
        try:
            os.makedirs(dir_path)
        except Exception as e:
            print("文件夹已存在")
            print(e)

请问大家有什么方法可以让它找到正确的路径?

用winshell库
先pip install winshell
然后

import os
import winshell

desktop_path = winshell.desktop()
dir_path = os.path.join(desktop_path, str(name))
try:
    os.makedirs(dir_path)
except FileExistsError:
    print("文件夹已存在")