+ 1
What's the best method to parse through a dictionary to find matching entries when compared to another dictionary?
Ex: Dictionary_1 compared to Dictionary_2 = Output (unmatched entries) I'm working on a script to read pcap files and compare the output (via MAC address) to ARP tables.
1 Antwort
+ 2
Do you mean such code?
dict_a = {
'key_a':'value_a',
'key_b':'value_b',
'key_d':'value_d',
}
dict_b = {
'key_a':'value_a',
'key_c':'value_c',
'key_d':'value_D', # unmatch
}
unmatch = [key for key in dict_a
if key in dict_b
and dict_a[key] != dict_b[key]]
print(unmatch) # key_d