How do I find out the current runtime directory from within a Python script?
Use os.getcwd
. This will tell you the current working directory. If you create a new file with
fp = open('a.txt', 'w')
then a.txt
will be created in the current working directory. Use os.chdir
to change the working directory, if needed.