Filenotfounderror But File Exists
I am creating a Python application that imports many JSON files. The files are in the same folder as the python script's location. Before I moved the entire folder someplace else,
Solution 1:
"~"
isn't a real directory (and would not qualify as an "absolute path"), and that's why the open doesn't work.
In order to expand the tilde to an actual directory (e.g. /Users/23markusz
), you can use os.path.expanduser
:
import os
...
withopen(os.path.expanduser('~/Documents/CincoMinutos-master/settings.json'), 'a+') as f:
# Do stuff
Post a Comment for "Filenotfounderror But File Exists"