hexstrings = ["DE", "AD", "BE", "EF"] # big-endian 0xDEADBEEFbytes = bytearray(int(x, 16) for x in hexstrings)bytes = bytearray.fromhex("".join(hexstrings)) # Python 2.6 may need u""如果您有很多“ em”,那么值得一看,其中哪些是最快的。

hexstrings = ["DE", "AD", "BE", "EF"] # big-endian 0xDEADBEEFbytes = bytearray(int(x, 16) for x in hexstrings)bytes = bytearray.fromhex("".join(hexstrings)) # Python 2.6 may need u""如果您有很多“ em”,那么值得一看,其中哪些是最快的。