0

I'm trying to make a video downloader python program on windows. In my computer, the download folder is in C:\Users\Suraj\Downloads. If someone else uses my code in their computer, the download folder is in C:\Users*XYZ\Downloads. How to solve this directory problem(Suraj, XYZ)?

  • This answers your question: https://stackoverflow.com/questions/35851281/python-finding-the-users-downloads-folder – abdusco Jul 20 '19 at 08:36
  • 2
    Possible duplicate of [python - Finding the user's "Downloads" folder](https://stackoverflow.com/questions/35851281/python-finding-the-users-downloads-folder) – user2653663 Jul 20 '19 at 08:44

1 Answers1

0

For me it looks that you are looking for os.path.expanduser, which can be used following way:

import os
homepath = os.path.expanduser('~')
downloadspath = os.path.expanduser(os.path.join('~','Downloads'))

according to docs it should work in Linux as well Windows, but I did not test second, so please test it before use.

Daweo
  • 31,313
  • 3
  • 12
  • 25