python file path function

It happens that there is nothing to do recently, optimize a deployment script of the project, and revisit python
os.path.dirname( file ) # The directory where the current file is located is equivalent to that of the shell cd $(dirname $0;);pwd, and the output is only the directory
insert image description here

os.path.realpath( file ) will carry the script name
insert image description here

Guess you like

Origin blog.csdn.net/dxgzg/article/details/125418533