zlib module

import zlib

zlib.compress(data, level=-1) : return a bytes object containing the compressed data;

* data should be in bytes type, if not, convert it to, such as type 'str' to type 'bytes' with command 'str.encode(string_data)';

* the return is also a bytes object, can convert it to str using command 'bytes_obj.decode()';

following snapshot is the coding sample;

zlib module_第1张图片
zlib.compress(bytes_data, level)

你可能感兴趣的:(zlib module)