bitarray.to01() doesn't return only 0s and 1s in string (Python)
问题 I use the library bitarray to manage my bits conversion and to write a binary file in Python. The bitarray.to01() before writing to file is of length 4807100171 . For some reason I can't make sense of, after getting the bits fromfile ( b.fromfile(file) ) and then converted to a string of 0s and 1s with to01() , there is not only 0s and 1s in my string ( \x00 ) and then, when I work with it, I get this error: ValueError: invalid literal for int() with base 2: '0000000000000000\x00\x00\x00\x00