Help Putting Output in list with Unicode


#1

Hello! I am having issues with the below code. The output is correct, but I want it to be in a list with unicode.

sample_photo_rep["photo"]["tags"]["tag"]
for sample_tags_list in sample_photo_rep["photo"]["tags"]["tag"]:
    print sample_tags_list['raw']

current output:

Nature
Mist
Mountain

want output to be: [u'nature', u'mist', u'mountain']

Any help would be great!


#2

Did you try,

print sample_tags_list['raw'].decode('utf-8')

?

Eg.

strings = ['one', 'two', 'three']

unicode_strings = [item.decode('utf-8') for item in strings]

print unicode_strings

[u'one', u'two', u'three']