Why are the characters in the string being printed as integers?

-1

I have to parse an excerpt of code and explain its operation, but I can not figure out the output:

Code:

word_norm = 'mundo'.encode("utf8").lower()
for idx, value in enumerate(word_norm):
    print(idx, value);

Output

0 109
1 117
2 110
3 100
4 111

I do not understand the value of the variable value of the for loop. Any idea what the whole value means? I was hoping to see every character in the word world.

    
asked by anonymous 31.01.2018 / 22:03

1 answer

3

Function documentation encode() says that returns an array of bytes , so this is what you have, a collection of bytes , not characters. Either you should not use this function or you should use one that turns string back into decode() , which may not be what you wanted to do.

    
31.01.2018 / 22:36