pad binary string with a given byte value (python 3)

Nagy László Zsolt gandalf at shopzeus.com
Sat Sep 20 08:21:50 EDT 2014


> bytes/str.ljust()
>
>>>> def pad(b, n=16, c=b"\x0f"):
> ...     length = (len(b)+n-1)//n*n
> ...     return b.ljust(length, c)
Thanks!


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the Python-list mailing list