When using Python, the path frequently used files to read, to do a path different methods of reading way to organize:
Import os # os.path.dirname (__ file__) returns the .py file directory path1 = os.path.dirname ( __FILE__ ) Print (path1) # os.path.abspath (__ file__) returns the absolute .py file path (full path) path2 = os.path.abspath with ( __FILE__ ) Print (path2) # combination path3 = os.path.dirname (os.path.abspath with ( __FILE__ )) Print (path3) # the os.path.join ( ) stitching path Path4 = the os.path.join (os.path.dirname (os.path.abspath with ( __FILE__ )), ' 1.py ' ) Print (Path4)