A query to a database returns a tuple like this:
(u'Elia extends Feyenoord deal',)
Now I want to strip this down to the part which is in single quotes only, like a string. Something like:
'Elia extends Feyenoord deal'
How can I do this?
A query to a database returns a tuple like this:
(u'Elia extends Feyenoord deal',)
Now I want to strip this down to the part which is in single quotes only, like a string. Something like:
'Elia extends Feyenoord deal'
How can I do this?
Simple, just select the first element of the tuple (with index 0
), which is the string you want:
>>> result = (u'Elia extends Feyenoord deal',)
>>> result[0]
'Elia extends Feyenoord deal'
>>> type(result[0])
<class 'str'> # would be <type 'unicode'> in Python2.x