os.path模块

os.path模块主要用于文件的属性获取,点击文档地址

  1. os.path.abspath(path)
    return a normalized absolutized version of the pathname path. equal to os.path.normpath(os.path.join(os.getcwd(),path))
    dirPath = os.path.abspath(filename)
  2. os.path.basename(path)
    return the base name of pathname path. if it is /foo/bar/ returns an empty string " "
  3. os.path.dirname(path)
    return the directory name of pathname path.if it is /foo/bar returns /foo/
  4. os.path.exists(path)
    return True if path refers to an existing path
  5. os.path.isabs(path)
  6. os.path.isfile(path)
  7. os.path.isdir(path)
  8. os.path.join(path,*paths)
    join one or more path components intelligently
  9. os.path.normpath(path)
    normalize a pathname b collapsing redundant separators.
  10. 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.

你可能感兴趣的:(os.path模块)