python3 list int转bytes

>>> 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')


版权声明:本文为qq_34905587原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_34905587/article/details/111617977