How do I find out the current runtime directory from within a Python script?
+4
A:
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.
Martin Geisler
2009-05-30 14:48:33