I have a list compiled from excel cells, using python - say listlist
. Each element in the cell/list is in unicode. When I print the list as
print listlist
I see 'u' prepended to each member of the list. But when I print the list like
for member in listlist:
print member
I do not see the 'u' prepended to the member.
Can someone please explain to me why there is this difference? Is it defined in the xlrd module?
This is because print list
is equivalent to
print "[", ", ".join(repr(i) for i in list), "]"
repr(s)
is u"blabla"
for a unicode string while print s
prints only blabla
.
When printing the list, it shows each object within the list using the object's __repr__
When printing the object alone, it uses the object's __str__
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With