当前位置: 代码迷 >> 综合 >> python3 list int转bytes
  详细解决方案

python3 list int转bytes

热度:71   发布时间:2023-10-19 20:15:45.0
>>> s=[0x41,0x42,0x43]
>>> b''.join(map(lambda x:int.to_bytes(x,1,'little'),s))
b'ABC'

int 的 list 转bytes

>>> b'\x13\x23'.hex()
'1323'

bytes 类似于python 2 encode('hex')

>>> bytes.fromhex('1223')
b'\x12#'

类似于python 2 decode('hex')

  相关解决方案