请说明为什么要解包太多(我的 for 循环中的 ValueError)。尝试过 deb
naislist = [('CONTROL FILE', '0', '0', '0'),
('REDO LOG', '0', '0', '0'),
('ARCHIVED LOG', '.69', '.59', '3'),
('BACKUP PIECE', '46.54', '0', '192'),
('IMAGE COPY', '0', '0', '0'),
('FLASHBACK LOG', '10.15', '6.31', '82'),
('FOREIGN ARCHIVED LOG', '0', '0', '0')]
print "size of naislist is ",len((naislist))
heading = ('MAIN MENU', 'LEVELS', 'LEVEL2', 'LEVEL3')
rearrange = dict(zip((0, 1, 2, 3), (len(str(x)) for x in heading)))
for tu, x in naislist:
rearrange.update((i, max(rearrange[i], len(str(el)))) for i, el in enumerate(tu))
rearrange[4] = max(rearrange[4], len(str(x)))
forkit = '|'. join('%%-%ss' % rearrange[i] for i in xrange(0, 4))
print '\n'.join((forkit % heading,
'-|-'.join(rearrange[i] * '-' for i in xrange(4)),
'\n'.join(forkit % (a, b, c, d) for (a, b, c), d in naislist)))