Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Python (2.7) 中使用来自shutil 的rmtree 方法。
调用此方法时可能发生的所有异常是什么?
根据实现,您必须检查OSError. 但是您可以ignore_errors=True在调用时使用参数...忽略错误;)或提供一个回调onerror来检查执行文件删除期间的异常。(参见 shutil.rmtree 文档)
OSError
ignore_errors=True
onerror
除非你做一些非常时髦的事情,os.error并且OSError
os.error