Python Bytearray Printing

前端 未结 2 510
感情败类
感情败类 2020-12-18 19:36

I have an integer list in Python that should correspond to the following int values (which can be changed to hex byte values):

[10, 145, 140, 188, 212, 198,          


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 19:57

    >>> x = bytearray(b'\n\x91\x8c\xbc\xd4\xc6\xd2\x19\x98\x14x\x0f1q!\xdc|C\xae\xe0
    \xdc\xf1\xf1')
    >>> import binascii
    >>> print binascii.hexlify(x)
    0a918cbcd4c6d2199814780f317121dc7c43aee0dcf1f1
    

    Use binascii if you want all of it to be printed as a hex string

提交回复
热议问题