Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在html中将一行内容拆分为两列以更好地显示_Python_Html Table - Fatal编程技术网

Python 如何在html中将一行内容拆分为两列以更好地显示

Python 如何在html中将一行内容拆分为两列以更好地显示,python,html-table,Python,Html Table,我有一个sqlite数据库,数据的格式是-'value','timestamp'。 我最终使用html文件在flask应用程序上呈现数据 index.html如下所示: <!DOCTYPE html> <html> <head> <title>{{ title }} - XYZ</title> </head> <body>

我有一个sqlite数据库,数据的格式是-'value','timestamp'。 我最终使用html文件在flask应用程序上呈现数据

index.html如下所示:

    <!DOCTYPE html>
    <html>
    <head>
       <title>{{ title }} - XYZ</title>
       </head>
          <body>
            <h1>Page for Information</h1>
             <p style="color:blue;"></p>
             <table style="width:100%">
             {% for row in data%}
              <tr>
             <td> {{ row }} </td>
             </tr>
             {% endfor %}
             <tr>
             </table>
             </body>
            </html>
现在,flask应用程序打印的是非结构化的:

“17天”,“2018-11-30 13:52:55” “17天”,“2018-11-30 13:53:42”


在传递到html之前,是否需要拆分/删除偏旁/单引号?

您可以单独访问该行的变量。我用逗号分隔了这两个值,但您可以只留下一个空格:

<th>Value</th>
<th>Timestamp</th>
{% for row in data %}
    <tr>
        <td>{{ row[0] }}</td> <td>{{ row[1] }}</td>
    </tr>
{% endfor %}

每一行都是一个元组,是的,您需要通过索引来访问元组元素。我想我需要使用css样式来添加列之间的间距和边框/标题等?我已经更新了我的答案,将它们放在表格中的单元格中,并带有标题。如果这有效,请接受作为答案。
{{ row.value }}, {{ row.timestamp }}