Show hex value for all bytes, even when ASCII characters are present

后端 未结 2 1478
名媛妹妹
名媛妹妹 2020-12-11 02:30

In Python (3) at least, if a binary value has an ASCII representation, it is shown instead of the hexadecimal value. For instance, the binary value of 67 which

2条回答
  •  隐瞒了意图╮
    2020-12-11 03:16

    After installing my package all-escapes there will be a new codec available for this usage.

    >>> b = bytes([10,67,128])
    >>> print(b.decode("all-escapes"))
    \x0a\x43\x80
    

提交回复
热议问题