0

Lets say I want to save some content in a JSON file, like this:

 with open('C:\\Users\\my_user\\Downloads\\test.json','w') as new_f:
        json.dump(found_database, new_f, indent=4, sort_keys=True)

And I want to save it into the Downloads folder of the users' machine.

How can I set the path to the Downloads folder not knowing the user/computer name? Something like this:

with open('C:\\Users\\%user name%\\Downloads\\test.json','w') as new_f:

If the user is from a different country, like an Asian one, does the structure of the path changes? I mean, do they use the same backslash as we use to do it? If not, is there a way to make the path work in any machine, no matter the country?

Also, for instance, in Brazil they use C:\Usuários instead of C:\Users. Is this a problem when trying to do it?

Thank you!

Lit2000hania
  • 97
  • 11
  • 1
    This might be helpful to you; https://stackoverflow.com/a/48706260/5594257 – adam Dec 15 '20 at 10:52
  • 1
    Does this answer your question? [python - Finding the user's "Downloads" folder](https://stackoverflow.com/questions/35851281/python-finding-the-users-downloads-folder) – deadshot Dec 15 '20 at 10:54
  • 1
    I found this and i think it might help you https://stackoverflow.com/a/35851955/12678128 – WMordy Dec 15 '20 at 10:55

0 Answers0