Articles → PYTHON → Bytearray In PythonBytearray In PythonIn this article, we will discuss bytearray in Python.What Is Bytearray? ByteArray is an array of bytes. It is a sequence of integers in the range from 0 to 256.Syntax bytearray(size) Or bytearray(b’string’)If we are passing the string, then it should start with b.Example size = 5 arr = bytearray(size) print(arr)The above program returns an array with the size of 5. All the values will be ‘\x00’ i.e., null.Output The Second Example arr = bytearray(b"Test") print(arr)Output Posted By - Karan Gupta Posted On - Friday, May 3, 2019 Query/Feedback Your Email Id Subject Query/Feedback Characters remaining 250
bytearray(size) Or bytearray(b’string’)
size = 5 arr = bytearray(size) print(arr)
arr = bytearray(b"Test") print(arr)
Query/Feedback