您的位置:首页 > 编程语言 > Python开发

python从sqlite读取并显示数据的方法

2015-05-08 12:16 776 查看
import cgi, os, sys
import sqlite3 as db
conn = db.connect('test.db')
cursor = conn.cursor()
conn.row_factory = db.Row
cursor.execute("select * from person")
rows = cursor.fetchall()
sys.stdout.write("Content-type: text.html\r\n\r\n")
sys.stdout.write("")
sys.stdout.write("<html><body><p>")
for row in rows:
sys.stdout.write("%s %s %s" % (row[0],row[1],row[2]))
sys.stdout.write("<br />")
sys.stdout.write("</p></body></html>")

希望本文所述对大家的Python程序设计有所帮助。

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python sqlite