我想在 python 中格式化我的 html 代码。
我的 Python 文件是:
titles = ['aaa', 'bbb', 'ccc', 'ddd', 'eee']
html_text = """<html>
<head>
<style type="text/css">
table { border-collapse: collapse;}
td { text-align: center; border: 5px solid #ff0000; border-style: dashed; font-size: 30px; }
</style>
</head>
<body>
<table width="100%" height="100%" border="5px">
<tr>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
</table>
</body>
</html> % (titles[0], titles[1], titles[2], titles[3], titles[4])"""
f = open('temp.html', 'w')
f.write(html_text)
f.close()
我想让那些 %s 成为 titles[0]、titles[1]、titles[2]、titles[3]、titles[4]。
我怎样才能做到?
明月笑刀无情
慕斯709654
ibeautiful
相关分类