I want get the full directory path of current file. I tried
os.path.abspath(__file__)
But it return the full path including the file.
C:\\python27\\test.py
Where as I just need
C:\\python27\\
I want get the full directory path of current file. I tried
os.path.abspath(__file__)
But it return the full path including the file.
C:\\python27\\test.py
Where as I just need
C:\\python27\\
If you mean the directory of the script being run:
import os
os.path.dirname(os.path.abspath(__file__))
Though, calling abspath isn't necessary since dirname will give you a proper directory name.
If you mean the current working directory:
import os
os.getcwd()