encoding – Python decoding Unicode is not supported

encoding – Python decoding Unicode is not supported

Looks like google.searchGoogle(param) already returns unicode:

>>> unicode(ufoo, utf-8)

Traceback (most recent call last):
  File <pyshell#1>, line 1, in <module>
    unicode(ufoo, utf-8)
TypeError: decoding Unicode is not supported

So what you want is:

result = google.searchGoogle(param).encode(utf-8)

As a side note, your code expects it to return a utf-8 encoded string so what was the point in decoding it (using unicode()) and encoding back (using .encode()) using the same encoding?

encoding – Python decoding Unicode is not supported

Leave a Reply

Your email address will not be published. Required fields are marked *