我是 Python 学习者,尝试处理一些场景:
到目前为止,我有:
try:
# Do all
except Exception as err1:
print err1
#File Reading error/ File Not Present
except Exception as err2:
print err2
# Data Format is incorrect
except Exception as err3:
print err3
# Copying Issue
except Exception as err4:
print err4
# Permission denied for writing
Run Code Online (Sandbox Code Playgroud)
以这种方式实现的想法是捕捉所有不同场景的确切错误。我可以在所有单独的try/except块中做到这一点。
这可能吗?并且合理?