我有一個列表,我想解壓循環,但我遇到了一個問題。在for循環中解壓列表的列表問題?
>>> a_list = [(date(2010, 7, 5), ['item 1', 'item 2']), (date(2010, 7, 6), ['item 1'])]
>>>
>>> for set in a_list:
... a, b = set
... print a, b
...
2010-07-05 ['item 1', 'item 2']
2010-07-06 ['item 1']
>>>
>>> for set in a_list:
... for a, b in set:
... print a, b
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: 'datetime.date' object is not iterable
第一個如何工作,但第二個不是?