I have a numpy binary array like this:

```
np_bin_array = [0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

```

It was 8-bit string characters of a word originally, starting from the left, with 0's padding it out.

I need to convert this back into strings to form the word again and strip the 0's and the output for the above should be 'Hello'.

Thanks for your help!
['https://Stackoverflow.com/questions/42297695', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7580607/']
You can firstly interpret the bits into an array, using [`numpy.packbits()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.packbits.html), then convert it to an array of bytes by applying [`bytearray()`](https://docs.python.org/3.6/library/functions.html#bytearray), then `decode()` it to be a normal string.

The following code

```
import numpy
np_bin_array = [0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
print(bytearray(numpy.packbits(np_bin_array)).decode().strip("\x00"))

```

gives

```
Hello

```
This one works to me. I had a boolean array though, so had to make an additional conversion.

```
def split_list(alist,max_size=1):
    """Yield successive n-sized chunks from l."""
    for i in range(0, len(alist), max_size):
        yield alist[i:i+max_size]

result = "".join([chr(i) for i in (int("".join([str(int(j)) for j in letter]), base=2) for letter in split_list(np_bin_array, 8)) if i != 0])

```