I have a program using GUI elements and returns the error
cannot concatenate 'str' and 'instance' objects
The Code is:
def PeopleSearch():
query = SearchTerm
query = ('what is '+ query)
string = ("<center><font size = 14> " + query + ' </font></center><br><img src =picture')
j = 0
try:
gs = GoogleSearch(query)
gs.results_per_page = 100
results = gs.get_results()
The indentations have been changed. Hmm. SearchTerm is basically from a textbox.
Let me reproduce with a simpler example:
v = 42
query = ('what is ' + v)
You would get:
TypeError: cannot concatenate 'str' and 'int' objects
But now, if you simply call str
:
query = ('what is ' + str(v))
That will work. So you only have to make sure str(query)
returns what you expect. Be careful, I don't know what kind of object you are manipulating, but you should check if there is any method to get the string representation of it.
Related:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With