I have two tuples, details below:
t1 = [
['aa'],
['ff'],
['er']
]
t2 = [
['aa', 11,],
['er', 99,]
]
and I would like to get results like these below using python method similar to SQL's LEFT OUTER JOIN:
res = [
['aa', 11,],
['ff', 0,],
['er', 99,]
]
Please help me with this.
d2 = dict(t2)
res = [[k[0], d2.get(k[0], 0)] for k in t1]
来源:https://stackoverflow.com/questions/15099022/how-to-use-python-left-outer-join-using-for-list-dictionary-comprehensions-not