几句话
.
main = ['dayn is the one', 'styn is a main', 'tyrn is the third main']
lst2 = ['dayz', 'stzn', 'tyrm']
lst3 = ['styzerwe', 'tyrmadsf', 'dayttt']
lst4 = ['dayl', 'styyzt', 'tyrl']
keys= tuple(main)
data= tuple(lst2+lst3+lst4)
elem= [[e for e in data if e.startswith(keys[i][:3])] for i in(range(3))]
result= dict(zip(keys, elem))
print(result)
[
输出
]
{'dayn is the one': ['dayz', 'dayttt', 'dayl'], 'styn is a main': ['styzerwe', 'styyzt'], 'tyrn is the third main': ['tyrm', 'tyrmadsf', 'tyrl']}