bytes的hex和fromhex函數
bytes對象
hex函數:將bytes(b'\x00\x01\x02\x03\x04\x05')的值轉換成hexstr('000102030405')
fromhex函數:將hexstr轉為:bytes
十六進制字符串轉bytes 就得用這個,encode 是普通字符串用的
>>> bytes([0,1,2,3,4,5]).hex()
'000102030405'
>>> bytes.fromhex('000102030405')
b'\x00\x01\x02\x03\x04\x05'
>>> b'abcde'.hex()
'6162636465'
>>> a = bytes.fromhex('6162636465')
>>> a
b'abcde'