1import os
2def GetScriptPath():
3 return os.path.realpath(__file__);
4
5print(GetScriptPath());
1from pathlib import Path
2
3current_file: Path = Path(__file__).resolve()
1# Python program get current working directory using os.getcwd()
2
3# importing os module
4import os
5
6# Get the current directory path
7current_directory = os.getcwd()
8
9# Print the current working directory
10print("Current working directory:", current_directory)
11
12# Get the script path and the file name
13foldername = os.path.basename(current_directory)
14
15scriptpath = os.path.realpath(__file__)
16# Print the script file absolute path
17print("Script file path is : " + scriptpath)