Inserting unicode MYSQL results within Python -


 if results:       line in results:            print line[0] + ' - ' + line[1] 

i need insert '-' between line[0] , line[1], when enter above code, error message 'coercing unicode: need string or buffer, int found'. suggestions on way around this?

thanks in advance.

the problem line[0] or line[1] holding int number.

by using "+" , 'some string' telling python please append string next string, have int interpreter raising problem.

try use:

if results: line in results: print str(line[0]) + ' - ' + str(line[1])

"+" note in python change it's "action" when meeting different data types. it's powerful feature default cannot add different datatypes.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -