擅长:python、mysql、java
<p><a href="https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions" rel="nofollow noreferrer">List comprehensions</a>是你的朋友!你知道吗</p>
<pre><code>matched = [i for i in daltonCarList if i in userCarList]
if matched:
print "Cool, we liked some of the same cars!"
print matched
</code></pre>
<p>这段代码将生成一个新的列表,其中包含来自道尔顿和用户的匹配项。你知道吗</p>
<p>如果你想看看两个列表是否完全相同,你的答案是<a href="https://stackoverflow.com/questions/8866652/determine-if-2-lists-have-the-same-elements-regardless-of-order">here</a></p>