0
这是我的代码:怎么办二级嵌套的地图
html_tags = [{'tag': 'a',
'attribs': [('class', 'anchor'),
('aria-hidden', 'true')]}]
我只是一个级别做for循环和一级映射如下:
for index, tag in enumerate(html_tags):
html_tags[index]['attribs'] = map(lambda x: '@{}="{}"'.format(*x), tag['attribs'])
print html_tags
但是,这是我的输出(结果):
[{'attribs': ['@class="anchor"', '@aria-hidden="true"'], 'tag': 'a'}]
如何执行两级嵌套映射并输出相同的结果。
什么是您预期的输出? –