我正在尝试捕获我正在使用的包(Openpyxl)的工作表错误异常.我尝试像这样导入异常,from openpyxl.utils import SheetTitleException但是我得到了错误"ImportError: cannot import name SheetTitleException".当我尝试导入它时from openpyxl.utils import *,我得到了错误NameError: global name 'SheetTitleException' is not defined.
我确定我输错了,但我不确定我哪里出错了.
这是我用来捕获异常的代码:
try:
bdws = bdwb[finalBDSheetName]
except SheetTitleException:
messageBox("Invalid sheet title. Check your sheet title and try again.")
return
Run Code Online (Sandbox Code Playgroud)