I need to create a dictionary like
d1={u'apple':True}
But I have "apple" in a string say str Problem is that if I write
>>> d1={}
>>> d[u'apple']=True
It works But if I write
>>> d1={}
>>> str="apple"
Then how to insert str in the unicode u added at the beginning?
u'...'produces an unicode object, but you don't need to use that syntax to convert a bytestring to a unicode object. You'd decode.