我收到不知道如何解决的错误too many values to unpack (expected 2)
。我使用Python 3.6。
for n in range(len(annotations)):
try:
fnam, fext = fname.split('.')
fn = '{}-{}.{}'.format(fnam, n+1, fext)
write_pages(annotations[n], os.path.join(fld.TEXTBLK, fn), verbose=False, **params)
# tables
tb = TextBlock(annotations[n].pages[0], **params)
tab, tab_fn = tb.extract_table(**tab_params, path=fld.TEXTBLK,
fname=fn, msgprefix=_msgprfx)
except Exception as e:
print('7')
logging.error('Error extracting textblocks from {}. {}'.format(fname, e))
errors_found = True
continue
拆分功能返回一个列表。因此,仅使用1个变量即可得到结果:
splitedval = fname.split('.')