Collection In Python Part -1
For professionals and freshers |
x=[10,20,30,40] => group of values but this is not a byte. to convert it into byte use byte() function
Example : x=[10,20,30,40]
type(x)
output: list
bytes(x)
type(x)
output : bytes
for i in b: print(x)
Note: If you want to represent group of object in range 0 to 256 ,immutable then we should go for byte.
byte and byteArray both are same only difference is that byte array is mutable whereas bytes is immutable.
When we use :
If u want to handle binary data images ,videos files then most commonly used collection is byte or byte array in any programming language.
x=[12,10,20,30]
b=bytearray(x)
b[0]=23
yes it is valid we can change value of byte array because it is mutable.
Note : Byte range should be in 0 to 256.
Comments
Post a Comment