通过使用OS库的函数可以获取路径。
当前文件的路径 os.path.abspath(__file__)
当前文件所在的目录 os.path.dirname(os.path.abspath(__file__))