Python fetchall方法获取tuple转到form表单逐条显示如何实现,fetchalltuple,python中用fetc
Python fetchall方法获取tuple转到form表单逐条显示如何实现,fetchalltuple,python中用fetc
python中用fetchall在数据中获得了一个tuple,请问怎么转到form表单中逐条显示呢?x谢谢。
form中同栏只有一个name,用如下代码传给form只能显示单条。
pythoncur.execute("SELECT title,sh_url FROM test")contents = cur.fetchall() for row in contents: title=row[0] sh_url=row[1] return render_template('list.html',title=title,sh_url=sh_url)
建议用列表表达式
cur.execute("SELECT title,sh_url FROM test")
articles = ((row[0], row[1]) for row in cursor.fetchall())
return render_template('list.html', {‘articles’: articles}
可以这样迭代数组
for title, url in articles
print ‘
编橙之家文章,
相关内容
- Django User类应用求高手赐教,djangouser,我最近在看一个
- 问Flask表单提交按钮时出错怎么解决?,flask表单,一组
- 我的python2版本安装提示失败,大家帮我看看错误原因在
- 求帮忙完善定时通过socket发送数据并能自动重启的程序
- Python Flask下载推广包功能脚本怎么写?,pythonflask,@inde
- Python Flask使用Nginx+uWSGI部署后无日志生成原因是什么,
- Pythonb包与模块该如何引用,pythonb模块引用,blog|app/blo
- MySQLdb insert_id写入问题求帮助,mysqldbinsert_id,python MySQ
- python语言中_和__作用与使用范围是什么,python使用范围
- python编码cherrypy库文件乱码,pythoncherrypy,我在encode里面
评论关闭