
It is a general buffer of bytes that you can work with. The io.BytesIO inherits from io.BufferedReader class comes with functions like read(), write(), peek(), getvalue(). Like push, pop, insert, append, delete, and sort. With a bytearray you can do everything you can with other mutables To create a mutable object you need to use the bytearray type. Of a single byte by using an index like an array, but the values can not be modified. The bytes type in Python is immutable and stores a sequence Watch this promo video about the course Working with Binary Data in Python 3 and visit the course on Udemy.Ĭourse on Udemy: Working with Binary Data in Python 3 Video: Bytes and Bytearray tutorial for Python 3 The Bytes Type I also have a course on this topic available on Udemy with videos for each section.

the base) to the int() method, which would make it infer the value: If the binary string has 0b (or 0B) radix prefix, then you may also specify 0 as the second argument (i.e.

ValueError: invalid literal for int() with base 2: '0o11111' Specifying an invalid binary number would raise the following error: This also works with binary strings that have the " 0b" (or " 0B") binary radix prefix: In Python, you can use the int() method (with a base 2 as the second argument) to convert a binary string to its integer equivalent, for example, like so:
