You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's weird. How are you running the script? Try using os.getcwd() to see what your working directory is.
IIRC, you shouldn't have to set the CWD to the location of the script unless you're running it from a different directory.
The default location should be the CWD, so if the script is in C:\directory and that's where you're running the script from, open() should be looking in that location for the file.
If CWD isn't the directory containing the script though, what you're doing fixes that problem fine.
I'm new to python so maybe i'm doing something wrong.
In the past when I've called open i have to specify the full path and I noticed the same thing with this bot.
with open('settings.json') as data:
That throws the following error in the console
IOError: [Errno 2] No such file or directory: 'settings.json'
importing
os
and adding the following fixes the issue:Is this correct, or, am I doing something wrong?
The text was updated successfully, but these errors were encountered: