flask - python 多維字典遍歷
問題描述
python多維數(shù)組遍歷問題:
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)
問題解答
回答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. 如何解決docker宿主機(jī)無法訪問容器中的服務(wù)?2. 前端 - CSS3 box-shadow如何設(shè)置,或者用什么方法可以產(chǎn)生圖中這樣陰影的效果。3. node.js - vue-cll+sass 樣式不出來 已經(jīng)npm install sass、 sass-loader了4. html - css 如何讓文字標(biāo)題顯示在邊框上?5. docker 下面創(chuàng)建的IMAGE 他們的 ID 一樣?這個(gè)是怎么回事????6. 在應(yīng)用配置文件 app.php 中找不到’route_check_cache’配置項(xiàng)7. html按鍵開關(guān)如何提交我想需要的值到數(shù)據(jù)庫8. html - 微信端video標(biāo)簽播放mp4視頻,安卓端提示視頻解析錯(cuò)誤9. HTML5中怎么判斷用戶是否正在瀏覽頁面?10. html5 - 微信開發(fā)的時(shí)候老是報(bào)這樣的錯(cuò)誤errmsg config invalid signature
