• Register
1 vote


My python program is encountering an encoding error. I’ve tried several methods already but still couldn’t fix the issue. Find the snippet below:

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

I can smell something silly in my code but I am unable to figure out the problem. here is the error message I am getting

exceptions.TypeError: decoding Unicode is not supported

Could anybody here solve the problem for me, please?

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote


Well, it seems like the google.searchGoogle(param) is already returning Unicode in your program. You may want to do:

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

Note: in your code, you may expect it to return an utf-8 encoded string so why did you put the decoding command using unicode() and then encoding it back using .encode()? Keep your code efficient always.


13 9 6
94,260 points

Related questions

1 vote
1 answer 3 views
Problem: Need to know how to fix this problem? No idea annotations attached to the jdk 1.8 android studio.
asked Mar 24 PkGuy 14k points
0 votes
1 answer 50 views
Problem: file was loaded in the wrong encoding utf-8 android studio.
asked Feb 22 Dan phillip 4.8k points
0 votes
0 answers 1 view
1 view
Problem: I am writing a Python (Python 3.3) program to send some data to a webpage using POST method. Mostly for debugging process I am getting the page result and displaying it on the screen using print() function. The code is like this: conn.request ... in many Windows instalations). So, the question: Is there a nicer solution that makes my code agnostic from the output interface encoding?
asked 5 days ago Atik03 14.9k points
0 votes
1 answer 11 views
Problem: I am stuck with this ... Please help me that how to deal with this error? attributeerror: module 'sys' has no attribute 'setdefaultencoding'
asked Mar 25 Ifra 25.7k points
0 votes
1 answer 8 views
Problem: How to I Solve this: # -*- coding: utf-8 -*- HELP! I need help understanding this: # -*- coding: utf-8 -*- Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 6 Mashhoodch 13k points
0 votes
1 answer 30 views
Problem : What may be the cause of the error: Unicodedecodeerror: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte.
asked Mar 6 Wafa Abu Yousef 6.1k points
1 vote
1 answer 2 views
Problem: How can I deal with this problem? One to one relationship in hibernate using annotations.
asked Mar 27 PkGuy 14k points
0 votes
1 answer 5 views
Problem: Please help me to solve it.
asked Mar 17 Ifra 25.7k points
1 vote
1 answer 8 views
Problem: I want to translate text from 1251 to utf-8, but can’t translate this. Plese help me to translate this.
asked Mar 5 Sabbir Hossain 14.6k points
0 votes
1 answer 2 views
Problem: What is the best way to do mobile&ie=utf-8?
asked 2 days ago padma1 27.4k points