If I have a file that stays in some directory, then how can I know from test.py Is it in the directory? Os.path.curdir will provide the current directory but not the directory where the file resides. If I invite test.py from some directory "foo", os.curdir will return to foo, but not the path of test.py.
Thank you.
How to obtain a directory of existing files:
import os. Path.abspath (os.path.dirname) (__file__))
Comments
Post a Comment