os.path.dirname(file) __file__的含义及解释
__file__不是通配符,而是一个变量,表示的是当前py文件的绝对路径(包括当前文件)。在python中双下划线属性和方法用于特殊目的。
os.path.dirname(file)表示py文件的绝对路径(不包括当前文件)
结果:
参考链接:https://stackoverflow.com/questions/9271464/what-does-the-file-variable-mean-do
__file__不是通配符,而是一个变量,表示的是当前py文件的绝对路径(包括当前文件)。在python中双下划线属性和方法用于特殊目的。
os.path.dirname(file)表示py文件的绝对路径(不包括当前文件)
结果:
参考链接:https://stackoverflow.com/questions/9271464/what-does-the-file-variable-mean-do