my_text = 'Welcome to Inlarn'
my_text_sample = b'Welcome to Inlarn'
What is Bytes datatypes in Python
Bytes is an immutable variant of bytearray with the same non-mutating methods, indexing, and slicing behaviour as bytearray. bytearray() is a function that returns a list of bytes. Return a new byte array. The bytearray type is a modifiable series of integers in the range 0 to x 256 that can be changed.
What is prefix b in python programming
Bytes are literals that represent integers between 0 and 255, commonly known as octets, whereas str is a literal that has a sequence of Unicode characters encoded in UTF-16 or UTF-32, and this is entirely dependent on Python compilation. By appending the prefix b to a regular string, we were able to transform its datatype from string to bytes.