flask - python 多維字典遍歷
問題描述
python多維數組遍歷問題:
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}}
現在想遍歷這個字典:
<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>
但是這樣遍歷數組好像不行耶,求指點
問題解答
回答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
相關文章:
1. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. mac里的docker如何命令行開啟呢?4. 關于docker下的nginx壓力測試5. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題6. nignx - docker內nginx 80端口被占用7. docker容器呢SSH為什么連不通呢?8. 如何解決Centos下Docker服務啟動無響應,且輸入docker命令無響應?9. docker start -a dockername 老是卡住,什么情況?10. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下

網公網安備