Ok.. This might be the duplicate.. but I dont think I even know the right problem.
I am guessing I have a string in unicode.. (basically i am reading from mongo db.. and mongodb stores everything in that form???? Honestly I am not sure.. but this is what I get..
{ u'preview': u'Hello World!!'}
so there is this u’ in front of all the fields..
I am basically trying to extract these out!! and then append them in one giant string.
so lets say I do something like:
string = ''
resolve = foo['first_resolved_at']
string += resolve
So it throws an error
TypeError: coercing to Unicode: need string or buffer, NoneType found
What am I doing wrong?
I guess I have to convert it to a string.. but how???
Thanks
Even though the answer was accepted, I thought I would include for reference an example of how you should be using join() instead of adding strings together. This also shows you that its avoiding None values:
And if what you wanted to do was only loop over a predetermined set of keys:
Here is a test showing the difference between this approach, appending to a list, and adding strings together:
You can see that when your loops get bigger it really makes a difference.