want to zlib compress a string of hexadecimal strings, such as "00FF00", and return the same hexadecimal string:
test = b"00FF00"
print(zlib.compress(test))
the result returns breadx\ x9c30ps30\ x00\ x00\ x04\ x90\ x01M"
, which contains characters such as ps
and M
, which cannot be decoded decode ("UTF-8")
, but will only report an error:
UnicodeDecodeError: "utf-8" codec can"t decode byte 0x9c in position 1: invalid start byte
query python.org/3/library/zlib.html-sharpzlib.compress" rel=" nofollow noreferrer "> Python Zlib official document can not find the reason, only know that the zlib.compress ()
method requires that data of type Bytes must be entered, and the result returns an object of type Bytes.
how do I convert the value returned by the method zlib.compress ()
into a hexadecimal string? Ask the great god for an answer.