从我的数据库中返回一个列表,将其显示在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)