0

I have a python file called main.py which is in my project/src folder

import json
import os

with open("../dependencies/data/foobar.json", "r") as file:
    data = json.load(file)
    for results in data:
    result = data.get("foobar")
    print(re)

I also have a json file in project/dependencies/data/foobar.json

I want to acces it using os module.

I want it to find the folder even if when calling the file in terminal from a different directory.

The problem is when I call the file from the src folder in terminal. It is working fine.

But when I am in the project folder in the terminal, It is throwing an error.

Is there any way to solve this problem using python

Thanks for helping out

0 Answers0