I\'m getting this error in my python program: ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters
This
I think this is harsh/overkill and it seems painfully slow, but my program is still quick and after struggling to comprehend what was going wrong (even after I attempted to implement @John's cleaned_string implementation), I just adapted his answer to purge ASCII-unprintable using the following (Python 2.7):
from curses import ascii
def clean(text):
return str(''.join(
ascii.isprint(c) and c or '?' for c in text
))
I'm not sure what I did wrong with the better option, but I just wanted to move on...