Bootstrap

jinja2了解

文件名template.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<center>
<table border="1">
    <thead>
        <th style="width:200px">订单编号</th>
        <th style="width:200px">用户邮箱</th>
        <th style="width:200px">创建时间</th>
        <th style="width:200px">支付时间</th>
        <th style="width:200px">支付方式</th>
        <th style="width:200px">支付状态</th>
    </thead>
    <tbody>
    {% for i in send_list %}
        <tr>
         {% for j in i %}
    <td><center style="font-size:16px";>{{j}}</center></td>
            {% endfor %}
  </tr>
    {% endfor %}
    </tbody>
</table>
    </center>
</body>
</html>
import jinja2,time
TP_one = ["asdasd",6,7,"sadasdasdasdasddfg",9,10]
send_list = []
for i in range(20):
    send_list.append(TP_one)
with open('template.html','r',encoding='utf-8') as pl:
    r_data = pl.read()
    temp = jinja2.Template(r_data)
    new_template = temp.render(send_list=send_list)
    print(new_template)
with open("second_TP.html",'w',encoding='utf-8') as fl:
    fl.write(new_template)


;