>>> LoL=[1,2,3,4]
>>> len(LoL) == n and {len(l) for l in LoL} == {n}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <setcomp>
TypeError: object of type 'int' has no len()
Vs,如果您对将要使用的数据有疑问:
>>> try:
... Â Â Â i=LoL[2][2]
... except IndexError:
... Â Â Â print 'no bueno...'
...
no bueno...