-2

How to write a string in a file ensuring that there is no nul byte character in a string in python?

f.write(x1+','+x2+','+x3)
J...S
  • 5,079
  • 1
  • 20
  • 35

1 Answers1

0

Just replace '\x00' your input string by an empty character.

In your example that would look like this :

data = x1+','+x2+','+x3
data = data.replace('\x00' , '')
f.write(data)
Chuk Ultima
  • 987
  • 1
  • 11
  • 21