lvxinzhi 发表于 2007-01-18 12:02

rmdir 与removedirs 有什么区别?

请问rmdir 与removedirs 有什么区别?谢谢

limodou 发表于 2007-01-18 12:48

建议去看文档。

KaMakA 发表于 2007-01-22 17:54

是不是很无语?
我跟踪学习.

removedirs( path)

Removes directories recursively. Works like rmdir() except that, if the leaf directory is successfully removed, removedirs() tries to successively remove every parent directory mentioned in path until an error is raised (which is ignored, because it generally means that a parent directory is not empty). For example, "os.removedirs('foo/bar/baz')" will first remove the directory "'foo/bar/baz'", and then remove "'foo/bar'"and "'foo'" if they are empty. Raises OSError if the leaf directory could not be successfully removed. New in version 1.5.2.

SilenceGene 发表于 2016-02-01 11:42

os.removedirs() 方法用于递归删除目录。像rmdir(), 如果子文件夹成功删除, removedirs()才尝试它们的父文件夹,直到抛出一个error(它基本上被忽略,因为它一般意味着你文件夹不为空)。
页: [1]
查看完整版本: rmdir 与removedirs 有什么区别?