I call a __repr__() function on object x as follows:
val = x.__repr__()
and then I want to store val string to SQLite database. The problem is
that val should be unicode.
I tried this with no success:
val = x.__repr__().encode("utf-8")
and
val = unicode(x.__repr__())
Do you know how to correct this?
I’m using Python 2.7.2
repr(x).decode("utf-8")andunicode(repr(x), "utf-8")should work.