<p>你可以使用来自<code>collections</code>的<code>defaultdict</code>,比如</p>
<pre><code>>>> a =[['sam', '2019-10-11'], ['ram', '2019-10-12'], ['king', '2019-10-11'],
... ['queen', '2019-10-10'], ['ram', '2019-10-12'], ['kumar', '2019-10-11'],
... ['jeba', '2019-10-11'], ['sam', '2019-10-10'], ['sam', '2019-10-11'],
... ['howl', '2019-10-14']]
>>>
>>> from collections import defaultdict
>>> d = defaultdict(set) # using `set` to not care about duplicate `name` on same `date`, otherwise use `list` instead of `set`
>>> # and use `d[date].append(name)`
>>> for name, date in a:
... d[date].add(name) # maybe, two users can be there for the same date ?
...
>>> data = [(k,len(v)) for k,v in sorted(d.items())]
>>> data
[('2019-10-10', 2), ('2019-10-11', 4), ('2019-10-12', 1), ('2019-10-14', 1)]
>>> list(zip(*data)) # returns a `list` of `tuple`s which usually should be fine for any iteration
[('2019-10-10', '2019-10-11', '2019-10-12', '2019-10-14'), (2, 4, 1, 1)]
>>> required = [list(x) for x in zip(*data)] # if you really want `list` of `list`s
>>> required
[['2019-10-10', '2019-10-11', '2019-10-12', '2019-10-14'], [2, 4, 1, 1)]]
</code></pre>