擅长:python、mysql、java
<p>我使用列表理解的实现。列表名('itemn')存储在superItem dict中,因此您可以在需要时获取它。你知道吗</p>
<pre><code>item1 = ["test1", "test2"]
item2 = ["test3", "test4"]
item3 = ["test5"]
superItem = {
'item1': item1,
'item2': item2,
'item3': item3
}
check = "test1"
result = [x for x in superItem if check in superItem[x]]
print result
</code></pre>
<p>性能测试:</p>
<pre><code>$ time python2.7 sometest.py
['item1']
real 0m0.315s
user 0m0.191s
sys 0m0.077s
</code></pre>