【发布时间】:2021-06-24 14:01:53
【问题描述】:
try:
return load(file)
except FileNotFoundError:
try:
return load(otherfile)
except FileNotFoundError:
return None
如何写得更干净?我觉得必须有更好的方法来完成这个(我假设当其他两个文件失败时会加载第三个文件)
【问题讨论】:
-
for f in file_list: try: return load(f) except ......?
标签: python exception try-except