0

Here is the example of my array:

b'[\x00{\x00"\x00s\x00u\x00b\x00i\x00d\x00"\x00:\x006\x002\x008\x003\x007\x00,\x00"\x00n\x00a\x00m\x00e\x00"\x00:\x00"\x00B\x00e\x00y\x00o\x00n\x00d\x00\x00E\x00y\x00e\x00s\x00"\x00,\x00"\x00p\x00r\x00i\x00c\x00e\x00"\x00:\x00"\x001\x001\x008\x00\x00p\x00C\x041\x04.\x00"\x00,\x00"\x00l\x00i\x00n\x00k\x00"\x00:\x00"\x00a\x00p\x00p\x00/\x003\x005\x006\x000\x005\x000\x00"\x00}\x00]\x00'

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 \x00

Moses Koledoye
  • 77,341
  • 8
  • 133
  • 139
Berman
  • 143
  • 11

1 Answers1

1

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')
'[{"sub'
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • Thank you! I was trying to decode it with utf-8 all the time and I've forgotten about utf-16 – Berman Jun 08 '16 at 08:12