You can achieve this using set()
with itertools.chain()
and map()
as:
>>> from itertools import chain
>>> a=['ketab khaneh','danesh gah', 'shi rin i']
>>> b=['ketab khaneh','dan esh gah','shirin i']
>>> set(chain(*map(str.split, a))).intersection(chain(*map(str.split, b)))
set(['i', 'khaneh', 'ketab', 'gah'])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…