gpt4 book ai didi

python - 查找用户的 "Downloads"文件夹

转载 作者:太空狗 更新时间:2023-10-29 17:30:03 25 4
gpt4 key购买 nike

我已经找到了this question这建议使用 os.path.expanduser(path) 来获取用户的主目录。

我想通过“下载”文件夹实现同样的目的。我知道this is possible in C# ,但我是 Python 的新手,不知道这在这里是否也可行,最好是独立于平台的(Windows、Ubuntu)。

我知道我可以做 download_folder = os.path.expanduser("~")+"/Downloads/",但是 (at least in Windows) it is possible to change the Default download folder .

最佳答案

from pathlib import Path
downloads_path = str(Path.home() / "Downloads")

关于python - 查找用户的 "Downloads"文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35851281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com