所以我想比较两条十六进制线并找出差异。但我希望它不仅能显示出差异,而且能取代所有的差异。
I wanna to turn this :
E2 34 3D A6 00 C2 00 95
79 34 C0 AB 00 C2 00 95
Into this :
?? 34 ?? ?? 00 C2 00 95
你可以这样做,
l1 = "E2 34 3D A6 00 C2 00 95"
l2 = "79 34 C0 AB 00 C2 00 95"
" ".join(i if i==j else '??' for i,j in zip(l1.split(), l2.split()))
# '?? 34 ?? ?? 00 C2 00 95'