one 文件夹 已经存在

exit(...)
exit([status])
Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status is an integer, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).
若 output_dir 已经存在 报错

two 若文件夹 事先不存在

若output_dir 事先不存在, 不报错了
原因是因为我后面加了if 判断部分的代码

本文探讨了在Python中如何处理文件夹已存在或不存在的情况,特别是在创建输出目录时的常见错误。通过添加适当的if判断代码,可以避免因output_dir已存在而引发的错误,并确保代码在文件夹不存在时能够正常运行。
1万+

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



