Table of Contents

5. Bytes

A raw bytes sequence type.

5.1. Creation of bytes sequence


In [ ]:
a = b'hello'
print(type(a))

In [ ]:
print(a)

5.2. Indexing in a bytes sequence


In [ ]:
chr(a[1])

5.3. Concatenation of bytes sequences


In [ ]:
b = b'world!'
print('"b" is in', id(b))
c = a + b' ' + b
print(c)

5.4. Bytes are inmutable


In [ ]:
a = b'abc'
print(id(a))
a += b'efg'
print(id(a))