Let's say this is my folder structure,
project
main_folder
file.py
json_files_folder
one.json
two.json
three.json
When I run the file.py file it should fetch the path of the files in json_files_folder and open a file,
Here is my code,
import json
import os
try:
file_path = os.path.dirname(os.path.realpath(__file__))
filename = file_path + '/' + 'one' + '.json'
with open(filename) as file:
data = json.load(file)
return data
except:
return "error"
what should I change in file_path variable to make this code work? Thanks in advance!
import os p = os.path.abspath('..')if you need the answer please comment