擅长:python、mysql、java
<p>尝试将<code>(lstOfitems,ListOfkeys)</code>更改为<code>zip(lstOfitems,ListOfkeys)</code>。<code>(lstOfitems,ListOfkeys)</code>只是一个<code>tuple</code>由两个<code>list</code>组成,您无法将其解包。但是,Python的内置<a href="https://docs.python.org/3.4/library/functions.html#zip" rel="nofollow">^{<cd6>}</a>函数将返回一个元组迭代器,其中第i个元组包含每个参数序列或iterables的第i个元素;这正是您想要的。你知道吗</p>
<p>但是,更好的方法是使用字典中的'items<code>method:</code>for b,a来访问字典键/值对删除计数项():`</p>
<p>话虽如此,您是否知道Python <code>collections</code>有一个名为<a href="https://docs.python.org/2/library/collections.html#collections.Counter" rel="nofollow">^{<cd10>}</a>的<code>dict</code>子类,它可以做您想要的事情?你可以这样使用它:</p>
<pre><code>from collections import Counter
c = Counter('gallahad') # a new counter from an iterable
# c will then be: Counter({'a': 3, 'l': 2, 'h': 1, 'g': 1, 'd': 1})
</code></pre>