如何转换此格式十六进制



我需要转换这个数字的格式:

CB0D8A83 7FBC1D22 86388A2D AFA0B9A1

我读了这个数字:

ciphertext= (ser.read(45))
print(ciphertext)
Ciphertxt_file.write(ciphertext)

到这个格式:

cb0d8a837fbc1d2286388a2dafa0b9a1

如果您能帮助我,我将不胜感激。

只需使用 .lower() 将它们转换为小写,并使用 .replace(' ','') 删除空格:

result = ciphertext.lower().replace(' ','')

无需在此处使用高级工具。但是,这不是二进制格式(二进制格式使用零和一,如00110101101110)。此外,此方法不检查格式,因此1134ZZ223也会被接受。

最新更新