Say the path of the file \'file1.txt\' is /home/bentley4/Desktop/sc/file1.txt Say my current working directory is /home/bentley4
/home/bentley4/Desktop/sc/file1.txt
/home/bentley4
i
You will get the path with os.path.abspath(__file__).
os.path.abspath(__file__)