TypeError:'builtin_function_or_method'对象是不可迭代的,如何将带有列表的字典添加到html UI

问题描述 投票:0回答:1

我是FE网的新手,

我正在尝试显示一个数据表,该数据表是由包含列表的字典构造的。 mt后端是python瓶。

这是我的mako代码:

<div class="row align-to-center">
            <table id="example" class="display" style="width:100%">
        <thead>
            <tr>
                <th>Source</th>
                <th>Destination</th>
                <th>Service</th>
                <th>Action</th>
                <th>Source zone</th>
                <th>Destination zone</th>
                <th>UID</th>
            </tr>
        </thead>
        <tbody>
        % for key, value in rules.items:
            % for src in value["src_network"]:
                % for dst in value["dst_network"]:
                   % for service in value["dst_service"]:
            <tr>
                <td>${src["name"]}</td>
                <td>${dst["name"]}</td>
                <td>${service["name"]}</td>
                <td>${value["action"]}</td>
                <td>${value["from_zone"]}</td>
                <td>${value["to_zone"]}</td>
                <td>${key}</td>
            </tr>
        % endfor
        % endfor
        % endfor
        % endfor
        </tbody></table>
    </div>
html dictionary bottle mako
1个回答
1
投票

您正在尝试迭代一个函数对象。您必须调用.items方法。

% for key, value in rules.items:更改为% for key, value in rules.items():

© www.soinside.com 2019 - 2024. All rights reserved.