如何在瓶子模板的列表中格式化和显示集合

2024-06-26 10:52:21 发布

您现在位置:Python中文网/ 问答频道 /正文

现状

索引\u template.tpl

{{links}}

输出结果

[{'http://www.oreilly.com/careers/', 'http://www.oreilly.com/about/editorial_independence.html', 'https://cdn.oreillystatic.com/pdf/oreilly_high_performance_organizations_whitepaper.pdf', 'https://www.youtube.com/user/OreillyMedia', 'https://www.safaribooksonline.com/?utm_medium=content&utm_source=oreilly.com&utm_campaign=lgen&utm_content=20170601+nav'}, {'http://www.oreilly.com/careers/', 'http://www.oreilly.com/about/editorial_independence.html'}, {'http://www.oreilly.com/careers/', 'http://www.oreilly.com/about/editorial_independence.html', 'https://cdn.oreillystatic.com/pdf/oreilly_high_performance_organizations_whitepaper.pdf', 'https://www.youtube.com/user/OreillyMedia'}]

我创建了以下代码,但如何用“,”分隔层次结构,以更易于理解的方式更容易地显示层次结构?

索引\u template.tpl

<html>
   <ul>
       %for item in links:
         <li>{{item}}</li>
       %end
   </ul>
</html>

输出结果

・{'http://www.oreilly.com/careers/', 'http://www.oreilly.com/about/editorial_independence.html', 'https://cdn.oreillystatic.com/pdf/oreilly_high_performance_organizations_whitepaper.pdf', 'https://www.youtube.com/user/OreillyMedia', 'https://www.safaribooksonline.com/?utm_medium=content&amp;utm_source=oreilly.com&amp;utm_campaign=lgen&amp;utm_content=20170601+nav'}
・{'http://www.oreilly.com/careers/', 'http://www.oreilly.com/about/editorial_independence.html'} 
・{'http://www.oreilly.com/careers/', 'http://www.oreilly.com/about/editorial_independence.html', 'https://cdn.oreillystatic.com/pdf/oreilly_high_performance_organizations_whitepaper.pdf', 'https://www.youtube.com/user/OreillyMedia'}

Tags: httpscomhttppdfhtmlwwwcdnabout

相关问题 更多 >