Python3 how to define one length byte-string?(Solved)

Just like any other byte string: b'\0' and b'^'.

Example:

>>> # Using strings
>>> s="test"
>>> s.ljust(6, '^')
'test^^'
>>>
>>> # Using bytes
>>> s = b'test' # note the `b` prefix
>>> s.ljust(6, b'^') # need `b` prefix
b'test^^'

Leave a Comment