2
Ich bin neu in Roboter und Python. Ich habe ein verschachteltes Wörterbuch, von dem ich Werte erhalten muss, aber ich kann nicht darauf zugreifen.Wie bekomme ich Werte aus verschachtelten Diktaten?
${result} = Get Info from_here=location mode=aggregate
@{keys}= Get Dictionary Keys ${result}
${robot_dict}= Create Dictionary
:FOR ${key} IN @{keys}
\ Set To Dictionary ${robot_dict} ${key}=${result['${key}']}
Log Many ${robot_dict}
######Output from robot_dict is:
#{'Name1':
# {'nickname':
# {'Name': 'Name1', 'FirstName': 'Full', 'Boy':
# {'Age': 'N/A', 'Single': '0'},
# 'Girl':
# {'Height': '229057', 'Weight': 'N/A'}
# }
# },
#'Name2':{'nickname':
# {'Name': 'Name2', 'FirstName': 'Full', 'Boy':
# {'raw_pkt_count': '229059', 'Age': 'N/A'},
# 'Girl':
# {'Height': '0', 'Weight': 'N/A'}
# }
# }
#}
#############
dies versucht:
${current_key} = Get Dictionary Keys ${robot_dict[Name1][nickname][Girl][Height]}
######Error: Resolving variable '${robot_dict[Name1][nickname][Girl][Height]}' failed: KeyError: 0
Und:
${current_key} = Get Dictionary Keys ${robot_dict} Name1.nickname.Girl.Height
#######Error: Dictionary does not contain key Name1.nickname.Girl.Height