For your hobbies


#1

my results seem odd: instead of getting a clean element in the list, I get the letter U in front of each element:

image


#2

its the u of unicode:

https://docs.python.org/2/howto/unicode.html


#3

Thank you. that clarifies this…
but it was not showing like this earlier…
is there some config or parameter I may have changed by mistake?
can I / should I change this back?


#4

result from raw_input is encoded as unicode:

print type(raw_input('enter something: '))

type() is a function which tells us data type.

the u of unicode only shows when you print the whole list, not each individual item. If you really want to get rid of it, you can always convert to string, but there is nothing wrong with using unicode


#5

Thank you very much for explaining:grinning:


#6

Forget you saw it. You probably don’t want to understand it yet and even then we’re talking about something not relevant and from a bad perspective.

Python2 didn’t distinguish very well between text and raw data, they shared the same type. In python3 they are separate types, and whenever talking to the outside world (files, network, printing, reading) you gotta convert between this data and text. Mostly this is done by python so that you appear to read and write text, not zeros and ones.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.