python - Finding the user's "Downloads" folder

Markus Weninger picture Markus Weninger · Mar 7, 2016 · Viewed 30.2k times · Source

I already found this question that suggests to use os.path.expanduser(path) to get the user's home directory.

I would like to achieve the same with the "Downloads" folder. I know that this is possible in C#, yet I'm new to Python and don't know if this is possible here too, preferable platform-independent (Windows, Ubuntu).

I know that I just could do download_folder = os.path.expanduser("~")+"/Downloads/", yet (at least in Windows) it is possible to change the Default download folder.

Answer

Shmidt picture Shmidt · Jun 30, 2020
from pathlib import Path
downloads_path = str(Path.home() / "Downloads")