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. 前端 - css3 3d效果问题2. python - 关于beautifulsoup获取文档内容3. javascript - 怎么实现让 div 里面的 img 元素 中心居中, 如下示例图4. javascript - nodejs调用qiniu的第三方资源抓取,返回401 bad token,为什么5. php - 微信开发验证服务器有效性6. javascript - vue+iview upload传参失败 跨域问题后台已经解决 仍然报403,这是怎么回事啊?7. Mac环境下QT编译MySQL驱动屡次失败?如何?8. 微信开放平台 - ios APP能不能打开微信然后通过微信跳转到指定的URL?9. javascript - vue引入样式的问题10. javascript - 移动端一个小效果
![dockerfile - [docker build image失败- npm install]](http://www.haobala.com/attached/image/news/202311/1028105a80.png)