title: Filtering out certain bytes in python
body: <p>I'm getting this error in my python program: <code>ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters</code></p>
  
  <p>This question, <a href="https://stackoverflow.com/questions/7037444/random-text-from-dev-random-raising-an-error-in-lxml-all-strings-must-be-xml-c">random text from /dev/random raising an error in lxml: All strings must be XML compatible: Unicode or ASCII, no NULL bytes</a>, explains the issue.</p>
  
  <p>The solution was to filter out certain bytes, but I'm confused about how to go about doing this. </p>
  
  <p>Any help?</p>
  
  <p>Edit: sorry if i didn't give enough info about the problem. the string data comes from an external api query of which i have no control over the how the data is formatted.</p>