listA = ["one", "two"]
listB = ["three"]
listC = ["four", "five", "six"]
listAll = listA + listB + listC
dictAll = {'all':listAll, 'A':listA, 'B':listB, 'C':listC,}
arg = ['foo', 'A', 'bar', 'B']
result = [dictAll[a] for a in arg if dictAll.has_key (a)]
我得到以下結果[「一」,「二」],[「三」] ,但我要的是[「一」,「二」,「三']解壓名單列表綜合
如何在列表理解中解開這些列表?
+1實際解釋爲什麼OP的代碼沒有得到所需的結果 – 2014-08-28 22:39:26
非常感謝!那回答了! – user3835779 2014-08-28 22:56:46