Compress Python Object in Memory

前端 未结 3 1267
萌比男神i
萌比男神i 2021-01-31 21:36

Most tutorials on compressing a file in Python involve immediately writing that file to disk with no intervening compressed python object. I want to know how to pickle and then

3条回答
  •  北海茫月
    2021-01-31 22:20

    Batteries included.

    >>> zlib.compress(pickle.dumps([42]))
    'x\x9c\xd3\xc8)0\xe0\xf241\xe2J\xd4\x03\x00\x10A\x02\x87'
    

提交回复
热议问题