1#Python 3
2
3#For the directory of the script being run:
4
5import pathlib
6pathlib.Path(__file__).parent.resolve()
7
8#For the current working directory:
9
10import pathlib
11pathlib.Path().resolve()
12
13#Python 2 and 3
14
15#For the directory of the script being run:
16
17import os
18os.path.dirname(os.path.abspath(__file__))
19
20#If you mean the current working directory:
21
22import os
23os.path.abspath(os.getcwd())
1from os import getcwd # only import "getcwd" from os
2
3getcwd() # Get the current working directory