PyDocs

Nav

Python Runtime Services

bytearray.resize

builtins

method of bytearray · Added in 3.14
  • bytearray.resize(size, /)
Resize the internal buffer of bytearray to len.

size
  New size to resize to.
1 Example
>>> def resize(ba, size):
...     if len(ba) > size:
...         del ba[size:]
...     else:
...         ba += b'\0' * (size - len(ba))
from the Python docs
See Also
No see-alsos for builtins/bytearray.resize
0 Notes
No notes for bytearray.resize