每当我试图用它们来移除里面有东西的dir时,我就会收到这个错误消息
import os
os.chdir('/Users/mustafa/Desktop')
os.makedirs('new-file/sub-file')
os.removedirs('new-file')
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 170, in removedirs rmdir(name) OSError: [Errno 66] Directory not empty: 'new-file'
但是我想我看到有人使用这些命令来删除不是空的目录,所以我做错了什么?谢谢
您应该使用^{} 递归删除目录:
回答你的问题:
是的,它们只能用于删除空目录。
下面是来自Python官方文档的描述,它清楚地说明了这一点。
^{}
^{}
相关问题 更多 >
编程相关推荐