pad binary string with a given byte value (python 3)
__peter__ at web.de
Sat Sep 20 14:37:22 CEST 2014
Nagy László Zsolt wrote:
>>>>>> def pad(b, n=16, c=b"\x0f"):
>>> ... length = (len(b)+n-1)//n*n
>>> ... return b.ljust(length, c)
> One more question. How do I create a single char binary string from a
> number? E.g.
> >>> bytes()
> It seems to be wrong again. The bytes constructor requires a sequence,
> and I don't like creating a list or a tuple just to convert it into a
> binary string.
Unfortunately I'm not aware of a function similar to chr() that creates
More information about the Python-list