flask - python 多維字典遍歷
問(wèn)題描述
python多維數(shù)組遍歷問(wèn)題:
net_interfaces:{’lo0’: {’name’: ’lo0’, ’ip’: ’fe80::1%lo0’, ’bytes_sent’: 79486408, ’bytes_recv’: 79486408, ’packets_sent’: 59982, ’packets_recv’: 59982, ’errors_in’: 0, ’errors_out’: 0, ’dropped_in’: 0, ’dropped_out’: 0}}
現(xiàn)在想遍歷這個(gè)字典:
<table class='table'> <thead> <tr> <th>Interface</th> <th>IP</th> <th>RX/s</th> <th>TX/s</th> </tr> </thead> <tbody> {% for ni in net_interfaces %} <tr> <td>{{ ni }}</td> <td>{{ ni.ip }}</td> <td>{{ ni.send_rate|default(0)|filesizeformat }}</td> <td>{{ ni.recv_rate|default(0)|filesizeformat }}</td> </tr> {% endfor %} </tbody></table>
但是這樣遍歷數(shù)組好像不行耶,求指點(diǎn)
問(wèn)題解答
回答1:{% for ni in net_interfaces.lo0 %}
回答2:for key,value in data
回答3:for i in data: print i,data[i],data[i].j回答4:
for key, value in data.items
相關(guān)文章:
1. javascript - 循環(huán)嵌套多個(gè)promise應(yīng)該如何實(shí)現(xiàn)?2. mysql優(yōu)化 - 關(guān)于mysql分區(qū)3. css3 - rem布局下,用戶瀏覽器的最小字號(hào)是12px怎么辦?4. javascript - ionic2 input autofocus 電腦成功,iOS手機(jī)鍵盤(pán)不彈出5. html5 - 如何實(shí)現(xiàn)帶陰影的不規(guī)則容器?6. objective-c - iOS開(kāi)發(fā)支付寶和微信支付完成為什么跳轉(zhuǎn)到了之前開(kāi)發(fā)的一個(gè)app?7. 前端 - IE9 css兼容問(wèn)題8. 請(qǐng)教各位大佬,瀏覽器點(diǎn) 提交實(shí)例為什么沒(méi)有反應(yīng)9. vue.js - vue 打包后 nginx 服務(wù)端API請(qǐng)求跨域問(wèn)題無(wú)法解決。10. css - 移動(dòng)端字體設(shè)置問(wèn)題
