简体   繁体   中英

Change and Access value of Python2.7 Dict Element

I am trying to modify a Python dict value. I think it may be to nested.

I tried:

for x in annotations:
  print(dict[x])

Which returns

[{'truePos': 0}, {'falseNeg': 0}, {'falsePos': 0}, {'precision': 0}, 'recall', 'f1']

Now I cannot access and change the {"truePos": 0}. (I want to for example, increment the value by 1 each time

What is the right way to do this in python2.7? Thanks very much

I added the full Dict in pastebin

Got it. The problem was that the first element had the length of 0

So I could not go deeper with

print(annotations[intent][0])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM