Method Signature:
resize(numBytes)
Parameters:
numBytes - The number of bytes to be increased or decreased on the bytearray.
Return value:
None. The size is modified on buffer itself. No copy of the bytearray is returned.
Overview:
The method resize() of the bytearray class increases or decreases the size of the bytearray by a given number of bytes. Increasing the size of the bytearray also zero initializes the newly acquired space of the bytearray. The method resize() does not return a new buffer. Instead, it just resizes the existing buffer.

Example:
|
# Example Python program that resizes a # Create a bytearray # Increase the size of the bytearray twofold # Decrease the size of the bytearray |
Output:
|
Initial bytearray: |