Slice a binary number into groups of five digits

后端 未结 7 1340
野性不改
野性不改 2021-01-21 07:34

Is there any neat trick to slice a binary number into groups of five digits in python?

\'00010100011011101101110100010111\' => [\'00010\', \'00110\', \'10111\', ... ]

7条回答
  •  情深已故
    2021-01-21 08:19

    Per your comments, you actually want base 32 strings.

    >>> import base64
    >>> base64.b32encode("good stuff")
    'M5XW6ZBAON2HKZTG'
    

提交回复
热议问题