python for loop printing list character instead of element -


this question has answer here:

i have list of dictionaries of when want print list index element of key in dictionary, output index of character , not element.

reader = csv.dictreader(mycsvfile, fieldnames)         row in reader:             print row 

example output:

{'name':'tom','numbers':"['1','2','3']"} #row 

print row['numbers']

['1',2','3'] #correct 

print row['numbers'][0]

[           #wrong 

how convert row['numbers'] list?

that's okay:

>>> row = {'name':'tom','numbers':['1','2','3']} >>> row['numbers'] ['1', '2', '3'] >>> row['numbers'][0] '1' >>> row['numbers'][1] '2' >>> row['numbers'][2] '3' >>>  

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -