Skip to content
← Back to Community
How do I find file directory of replit?
Profile icon
Stawa

I'm trying to open a json file with python using os.chdir() function.

Voters
Profile icon
DhruvMasiwal
Profile icon
DivyanshYT
Profile icon
Stawa
Comments
hotnewtop
Profile icon
Geocube101

If you want to open a file then use the open function
It returns a file handle to read (or write) files. Read the contents and then pass it through a json parser

with open("path/to/file.json", "r") as f: contents = f.read() # Do something with contents (like parse it into JSON)

os.chdir changes the current working directory and as such I don't think it can be used to open a file