手机
当前位置:查字典教程网 >脚本专栏 >python >python从sqlite读取并显示数据的方法
python从sqlite读取并显示数据的方法
摘要:本文实例讲述了python从sqlite读取并显示数据的方法。分享给大家供大家参考。具体实现方法如下:importcgi,os,sysimp...

本文实例讲述了python从sqlite读取并显示数据的方法。分享给大家供大家参考。具体实现方法如下:

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.htmlrnrn") 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读取并显示数据的方法】相关文章:

python实现网页链接提取的方法分享

python访问纯真IP数据库的代码

python操作MySQL数据库的方法分享

Python转码问题的解决方法

盘点提高 Python 代码效率的方法

python计数排序和基数排序算法实例

python操作日期和时间的方法

wxpython 最小化到托盘与欢迎图片的实现方法

python逐行读取文件内容的三种方法

python中使用sys模板和logging模块获取行号和函数名的方法

精品推荐
分类导航