【发布时间】:2017-12-08 14:21:46
【问题描述】:
从我的数据库中,我返回了一个要显示到我的 HTML 页面中的列表,但我的列表中有这个不需要的符号。我尝试使用split() 函数,但它不起作用。如何删除那些括号、逗号和引号。谢谢你的帮助
输出为:
[('cenomar',), ('cedula',), ('Birth Certificate',), ('Clearance',)]
我想要:
[cenomar, cedula, Birth Certificate, Clearance]
这是我的 python 函数:
@app.route('/')
def search():
conn=psycopg2.connect("dbname='forms' user='postgres' password='everboy'
host='localhost' port='5432'")
cur=conn.cursor()
cur.execute("SELECT name from form")
rows=cur.fetchall()
print(rows)
return render_template("form.html",rows=rows)
【问题讨论】:
-
您列出的每个元素似乎都是一个元组。您想获取元组中的数据吗?
标签: python python-3.x flask