os.path模块主要用于文件的属性获取,点击文档地址
-
os.path.abspath(path)
return a normalized absolutized version of the pathname path. equal toos.path.normpath(os.path.join(os.getcwd(),path))
dirPath = os.path.abspath(filename)
-
os.path.basename(path)
return the base name of pathname path. if it is /foo/bar/ returns an empty string " " -
os.path.dirname(path)
return the directory name of pathname path.if it is /foo/bar returns /foo/ -
os.path.exists(path)
return True if path refers to an existing path os.path.isabs(path)
os.path.isfile(path)
os.path.isdir(path)
-
os.path.join(path,*paths)
join one or more path components intelligently -
os.path.normpath(path)
normalize a pathname b collapsing redundant separators. -
os.path.split(path)
split the pathname path into a pair,(head,tail) where tail is the last pathname component and head is everything leading up to that.