I got this error while writing to a file like this:
f.write(str(data))
and the problem was I was calling str on some data that contained Unicode characters and the default "ascii" encoder does not know how to encode them to bytes. This I understand.
Then I did print unicode(data)[13:20]
to see the offending characters and I could not see anything. Is there a way to detect that ? Thanks.
Based on Steven Kryskala's suggestion I did print repr(unicode(data))[13:21]
and got this:
u'\n<body s'
Whats bad about that ?