python操作字节数组

创建字节数组

key = bytearray([0x13, 0x00, 0x00, 0x00, 0x08, 0x00])
key
>>bytearray(b'\x13\x00\x00\x00\x08\x00')

读取字节数组的数据

key[0]
>>19
key[1]=0xff
key
>>bytearray(b'\x13\xff\x00\x00\x08\x00')

转为字符串格式

bytes(key)
>>'\x13\xff\x00\x00\x08\x00'

你可能感兴趣的:(Python,python)