python模块详解 | os
osos.remove(path)
删除文件
os.remove(path)
- 删除文件os.removedirs(path)
- 删除空文件夹os.mkdir(dirname)
- 新建文件夹os.makedirs(path)
- 递归新建文件夹os.rmdir(path)
- 删除空文件夹os.rename(a,b)
- 重命名os.listdir(path)
- 返回路径下所有的文件及文件夹os.system("ls")
- 运行shell命令
os.path
os.path.getatime(path)
- 最近访问时间(时间戳)os.path.getctime(path)
- 文件创建时间(时间戳)os.path.getmtime(path)
- 最近修改时间(时间戳)os.path.getsize(path)
- 文件大小(字节为单位)os.path.abspath(path)
- 绝对路径os.path.normpath(path)
- path路径os.path.dirname(path)
- path的目录os.path.basename(path)
- path最后的文件名os.path.exists(path)
- 存在则返回Trueos.path.isabs(path)
- path是绝对路径则返回Trueos.path.isfile(path)
- path对象为文件,则返回Trueos.path.isdir(path)
- path对象为文件夹,则返回Trueos.path.join(path,file)
- 合并路径与文件名os.path.split(path)
- 将文件名和路径分割开os.path.splitext(path)
- 将文件名与拓展名分割开
更多内容猛击这里