1

Using the following code I was able to convert characters to bits:

msg= bitarray(endian='little')
msg.frombytes(b'ABCDEFGH')

How to convert it back bits to characters?

NOTE: This pertains to the bitarray package.

2
  • Is bitarray from the bitarray library? Commented Dec 17, 2013 at 19:22
  • Yes it is from bitarray, called by "from bitarray import bitarray". Commented Dec 17, 2013 at 19:38

1 Answer 1

3

A bitarray object has a tobytes() method as well:

bytes_value = msg.tobytes()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.