擅长:python、mysql、java
<p>您正在尝试迭代整数,因为<code>len</code>函数返回一个int。应该在外部位置使用range:</p>
<pre class="lang-py prettyprint-override"><code>mydict = {
'ServiceResult': {
'msgBody': {
'itemList': [{
'busRouteId': '100100016',
'busRouteNm': '110A',
}, {
'busRouteId': '100100015',
'busRouteNm': '110B',
}, {
'busRouteId': '165000146',
'busRouteNm': '1100',
}, {
'busRouteId': '165000147',
'busRouteNm': '1101',
}, {
'busRouteId': '218000011',
'busRouteNm': '1100',
}, {
'busRouteId': '222000074',
'busRouteNm': '1100',
}, {
'busRouteId': '235000085',
'busRouteNm': '1100',
}, {
'busRouteId': '234000879',
'busRouteNm': '1101',
}, {
'busRouteId': '204000082',
'busRouteNm': 'G8110',
}]
}
}
}
item_list = mydict['ServiceResult']['msgBody']['itemList']
for i in range(len(item_list)):
print(item_list[i]['busRouteId'])
</code></pre>