Reputation: 1392
After doing
symb = []
for unicodeOfSymbol in myList:
print unicodeOfSymbol.encode('UTF-8') # This prints out the symbol perfectly
symb.append(unicodeOfSymbol.encode('UTF-8'))
I tried to print symb but i got this which i think is byte string?
<type 'list'>: ['\xf0\x9f\x98\x82', '\xe2\x9c\xa8', '\xe2\x99\xa5', '\xf0\x9f\x92\x96', '\xe2\x99\xa1']
How do i get the symbols to be printed out in the list as it is? I am using python2.7
Upvotes: 0
Views: 29
Reputation: 74645
Like this:
>>> print '[' + ', '.join(['\xf0\x9f\x98\x82', '\xe2\x9c\xa8', '\xe2\x99\xa5', '\xf0\x9f\x92\x96', '\xe2\x99\xa1']) + ']'
[😂, ✨, ♥, 💖, ♡]
Upvotes: 2
Reputation: 531055
Just print each element of the list; printing the list as a single entity gives you the representation of the string, not the string itself. Compare
print(symb)
to
for x in symb:
print(x)
Upvotes: 2