Python bytes literal has extra characters that aren't hex, but alter the value of the string

后端 未结 3 727
借酒劲吻你
借酒劲吻你 2020-12-11 22:28

I am used to the python byte literal syntax representing bytes as hex values such as b\'\\x7a\' is the hex value 0x7a. I however have run into an i

3条回答
  •  抹茶落季
    2020-12-11 23:11

    Byte array notation converts certain values to their textual representation:

    >>> b'\x12\x41\x42'
    b'\x12AB'
    

    In this case the hex number 41 is the ASCII value for capital letter A.

提交回复
热议问题