Python 查找两个十六进制数据包之间的相似性十六进制点的代码
Python Code for find similarity hex points between two hex packet
我想在两个数据包之间找到相同的十六进制值示例:
example 1 : 0X 34 21 56 B3
ecample 2 : 5D 75 21 98 A3
我想得到“21”和“3”
谁能帮我解决这个问题
您可以同时遍历它们并比较值。
h1 = "0X342156B3" # Hex 1
h2 = "5D752198A3" # Hex 2
for i in range(10): # Modify the 10 to whatever value you need
if h1[i] == h2[i]: # Check if both values are the same
print(h1[i])
这会给
2
1
3
然后您可以随心所欲地使用它。
根据你想要的输出“3”,我假设你想按字符比较它们:
str1 = "0X 34 21 56 B3"
str2 = "5D 75 21 98 A3"
for c1, c2 in zip(str1.replace(" ", ""),str2.replace(" ", "")):
if c1 == c2:
print(c1)
我想在两个数据包之间找到相同的十六进制值示例:
example 1 : 0X 34 21 56 B3
ecample 2 : 5D 75 21 98 A3
我想得到“21”和“3”
谁能帮我解决这个问题
您可以同时遍历它们并比较值。
h1 = "0X342156B3" # Hex 1
h2 = "5D752198A3" # Hex 2
for i in range(10): # Modify the 10 to whatever value you need
if h1[i] == h2[i]: # Check if both values are the same
print(h1[i])
这会给
2
1
3
然后您可以随心所欲地使用它。
根据你想要的输出“3”,我假设你想按字符比较它们:
str1 = "0X 34 21 56 B3"
str2 = "5D 75 21 98 A3"
for c1, c2 in zip(str1.replace(" ", ""),str2.replace(" ", "")):
if c1 == c2:
print(c1)