I am wanting to package my program that uses over files to store user data locally, but I don't know what directory I should put in all the json.load
and json.dump
. So right now, I have the directory equal to json.dump(somelist,open('/home/username/filename','w'))
but when someone downloads it, the program won't work since it is a different directory. I am trying to PyInstaller but maybe PyInstaller will do it for me. I was just wondering and I couldn't find anything on google but if there is something, please link it to me. Thanks in advance!!
Asked
Active
Viewed 35 times
0

user3818089
- 345
- 1
- 2
- 19
1 Answers
1
Use the following to get the user's home directory:
from os.path import expanduser
home = expanduser("~")
with open(os.path.join(home, 'file'), 'w') as sr:
json.dump(somelist, sr)

simonzack
- 19,729
- 13
- 73
- 118