Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't find a JSON file even though they are in the same directory

I’m having a problem opening a JSON file, because it says that is doesn’t exists but, it does, it is in the same directory, here, you can see it:

enter image description here

But even though they are in the same folder, it says that it doesn’t exist:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

Here is the code where outputs the error:

with open('warn.json', 'r', encoding='utf-8') as f:
    guilds_dict = json.load(f)
    if str(id) in guilds_dict:
        guilds_dict[str(id)] += warns
    else:
        guilds_dict[str(id)] = warns

>Solution :

Try to use:

with open('/root/Nasgar/NasgarBot/cogs/moderation/warn.json', 'r', encoding='utf-8') as f:
    guilds_dict = json.load(f)
    if str(id) in guilds_dict:
        guilds_dict[str(id)] += warns
    else:
        guilds_dict[str(id)] = warns

This should work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading