os.walk() returns three values on each iteration of the loop:
-
The name of the current folder
-
A list of folders in the current folder
-
A list of files in the current folder
- os.rmdir() delete the directory which is empty,otherwise you can’t delete it directly.
- If you want to delete all of the directory ,then you can use os.rmtree().
本文详细介绍了Python中os模块的walk()和rmdir()函数的使用方法。walk()函数用于遍历指定目录下的所有子目录和文件,返回当前目录名、子目录列表和文件列表。rmdir()函数用于删除空目录,若要删除非空目录则需使用rmtree()函数。
684

被折叠的 条评论
为什么被折叠?



