abspath
返回一个目录的绝对路径
Return an absolute path.
>>> os.path.abspath("/etc/sysconfig/selinux")
'/etc/sysconfig/selinux'
>>> os.getcwd()
'/root'
>>> os.path.abspath("python_modu")
'/root/python_modu'
basename
返回一个目录的基名
Returns the final component of a pathname
>>> os.path.basename("/etc/sysconfig/selinux")
'selinux'
>>> os.path.basename("/usr/local/python3/bin/python3")
'python3'
dirname
返回一个目录的目录名
Returns the directory component of a pathname
>>> os.path.dirname("/etc/sysconfig/selinux")
'/etc/sysconfig'
>>> os.path.dirname("/usr/local/python3/bin/python3")
'/usr/local/python3/bin'
exists
测试指定文件是否存在
Test whether a path exists. Returns False for broken symbolic links
>>> os.path.exists("/home/egon")
False
>>> os.path.exists("/root")
True
>>> os.path.exists("/usr/bin/python")
True