Berman Berman - 10 months ago 31
Python Question

How to get rid of \x00 in my array of bytes?

Here is the example of my array:


is there any way to get rid of all the null characters? Any kind of replacing isn't the solution because the other symbols start with


Decode it to text. Or open the file with the correct encoding in the first place.

>>> b'[\x00{\x00"\x00s\x00u\x00b\x00'.decode('utf-16le')