Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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 带烧瓶的添加台_Python_Html_Flask_Jinja2 - Fatal编程技术网

Python 带烧瓶的添加台

Python 带烧瓶的添加台,python,html,flask,jinja2,Python,Html,Flask,Jinja2,在我的基本web应用程序中,当单击“计算”按钮时,可以有两个选项。 首先,只有一个结果,所以我直接向用户显示它们。 其次,可能有多个结果,所以我需要使用表来显示我的结果 对于第一个选项,我可以如下所示显示我的结果: <p>Result {{result}}</p> 结果{{Result} 但我无法确定我的“result”参数是否为array,以及如何在html文件的表中显示array的所有值 非常感谢您的帮助。您可以在模板中迭代您的iterable: Python脚

在我的基本web应用程序中,当单击“计算”按钮时,可以有两个选项。 首先,只有一个结果,所以我直接向用户显示它们。 其次,可能有多个结果,所以我需要使用表来显示我的结果

对于第一个选项,我可以如下所示显示我的结果:

<p>Result {{result}}</p> 
结果{{Result}

但我无法确定我的“result”参数是否为array,以及如何在html文件的表中显示array的所有值


非常感谢您的帮助。

您可以在模板中迭代您的iterable:

Python脚本:

users = [{"name": "123", "hash": "qwe"},]

@app.route('/index/')
def index_page():
    return render_template('index.html', users=users)
@app.route('/')
def index():
    return render_template('index.html', result='yes')
模板:

<table>
  <thead>
    <tr>
      <th><span>Hash - Name</span></th>
    </tr>
  </thead>
  <tbody>
    {% for user in users %}
    <tr>
      <td>
       <span>{{user['hash']}} - {{user['name']}}</span>
      </td>
    </tr>
    {% endfor %}
   </tbody>
</table>

散列名称
{users%%中的用户为%s}
{{user['hash']}}-{{user['name']}
{%endfor%}

有关在jinja2 templater中迭代循环的更多详细信息,请参阅。

您可以在模板中迭代iterable:

Python脚本:

users = [{"name": "123", "hash": "qwe"},]

@app.route('/index/')
def index_page():
    return render_template('index.html', users=users)
@app.route('/')
def index():
    return render_template('index.html', result='yes')
模板:

<table>
  <thead>
    <tr>
      <th><span>Hash - Name</span></th>
    </tr>
  </thead>
  <tbody>
    {% for user in users %}
    <tr>
      <td>
       <span>{{user['hash']}} - {{user['name']}}</span>
      </td>
    </tr>
    {% endfor %}
   </tbody>
</table>

散列名称
{users%%中的用户为%s}
{{user['hash']}}-{{user['name']}
{%endfor%}

有关在jinja2 templater中迭代循环的更多详细信息,请参阅。

您可以将
结果发送到python脚本中进行渲染:

users = [{"name": "123", "hash": "qwe"},]

@app.route('/index/')
def index_page():
    return render_template('index.html', users=users)
@app.route('/')
def index():
    return render_template('index.html', result='yes')
在坦帕尔特:

<p>Result {{ result }}</p>
结果{{Result}

在浏览器中:

<p>Result yes</p>
结果是


您可以将
结果发送到python脚本中进行渲染:

users = [{"name": "123", "hash": "qwe"},]

@app.route('/index/')
def index_page():
    return render_template('index.html', users=users)
@app.route('/')
def index():
    return render_template('index.html', result='yes')
在坦帕尔特:

<p>Result {{ result }}</p>
结果{{Result}

在浏览器中:

<p>Result yes</p>
结果是