我的脚本有以下行:
libro_dia = xlrd.open_workbook(file_contents = libro_dia)
当libro_dia
无效时,它会引发以下错误:
XLRDError: Unsupported format, or corrupt file: Expected BOF record; found '<!DOCTYP'
我想处理这个错误,所以我写:
try:
libro_dia = xlrd.open_workbook(file_contents = libro_dia)
except XLRDError:
no_termina = False
但它会引发以下错误:
NameError: name 'XLRDError' is not defined
这是怎么回事?