擅长:python、mysql、java
<p>对于第一个问题,使用<a href="https://docs.python.org/2/library/stdtypes.html#types-set" rel="nofollow noreferrer">^{<cd1>}</a></p>
<pre><code>import operator
lists = [['123', 'apple'], ['123', 'banana'], ['345', 'apple'], ['567', 'berry'], ['567', 'banana']]
nrof_users = len(set(map(operator.itemgetter(0), lists)))
print(nrof_users)
# 3
</code></pre>
<p>对于第二个问题,使用<a href="https://docs.python.org/2/library/collections.html#collections.Counter" rel="nofollow noreferrer">^{<cd2>}</a></p>
^{pr2}$