conn=MySQLdb.connect(host="localhost",user="root",passwd="",db="web")
cursor = conn.cursor()
cursor.execute("select * from weather")
entries = cursor.fetchall()
return render_template('test.html', entries=entries)
{% for entry in entries %}
<li><h2>{{ entry.id }}</h2>{{ entry.dara_from }}
{% else %}
<li><em>Unbelievable. No entries here so far</em>
{% endfor %}
为什么页面查看源码搜这样的
<li><h2></h2>
<li><h2></h2>
<li><h2></h2>
<li><h2></h2>
<li><h2></h2>
<li><h2></h2>
<li><h2></h2>
<li><h2></h2>
也就是说 字段没有显示,但是 列数是对的。我明明写的是 select * from