def dict_merge(a, b, k):
c = a.copy()<EOL>for j in range(len(b)):<EOL><INDENT>flag = False<EOL>for i in range(len(c)):<EOL><INDENT>if c[i][k] == b[j][k]:<EOL><INDENT>c[i] = b[j].copy()<EOL>flag = True<EOL><DEDENT><DEDENT>if not flag:<EOL><INDENT>c.append(b[j].copy())<EOL><DEDENT><DEDENT>return c<EOL>
Merge two dictionary lists
:param a: original list
:param b: alternative list, element will replace the one in original list with same key
:param k: key
:return: the merged list