我有一些带有两个for循环的逻辑,如下所示,我不希望为MainvalueInfo中的每个valueInfo重复“valueInfo ['valueInfo']中的值”, FYI MainvalueInfo如下所示,我只想运行一次“for MainvalueInfo中的valueInfo”来获取valueInfo和“for value in valueInfo ['valueInfo']” 应该重复每一个价值。有人建议怎么做才能做到这一点?
MainvalueInfo = {'Assignee': 'username', 'RCAInfo': 'Provided', 'PLProductLine': 'LNX.LA.0.0', 'valueInfo': [{'Url': 'https://review-android.company.com/761190', 'Status': 'MERGED', 'kw_ran': 'kw running', 'Info': 'ALREADY INTEGRATED', 'lookahead_ran': 'lookahead running'}, {'Url': 'https://review-android.company.com/777849', 'Status': 'NEW', 'kw_ran': 'kw did not run', 'Info': 'Available', 'lookahead_ran': 'lookahead running'}], 'CRId': '<a href="http://prism/CR/664310">664310</a>', 'CRStatus': 'Fix', 'RNotesStatus': 'Yes', 'TargetName': 'MSM8916', 'IsDevComplete': 'True'}
for valueInfo in MainvalueInfo: #I dont want the below block to be repeated for every value in MainvalueInfo
for value in valueInfo['valueInfo']:
................
答案 0 :(得分:0)
for key in MainvalueInfo:
if key =='valueInfo':
for value in MainvalueInfo[key]
else:pass
i think ur confused by naming conviction . try this .u understand better
run directly
for value in MainvalueInfo['valueInfo']:
不要循环mainvalueinfo然后