递归试试?
#!/bin/env python
#encoding=utf-8
# Author: Aaron Shao - shao.dut@gmail.com
# Last modified: 2015-01-15 12:07
# Filename:
test.py # Description:
a= [['Vodka'], ['Whisky'], ['Scotch'], ['Brandy']]
b = (['Vodka', 'today', 'nice', 'drink', 'Scotch'], 'Group 2')
def parse(x):
if isinstance(x, (tuple,list)):
result = set([])
for i in x:
pass
result = result | parse(i)
return result
elif isinstance(x, str):
return set([x])
else:
return set([])
x = parse(a)
y = parse(b)
print x & y