手机
当前位置:查字典教程网 >脚本专栏 >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中使用sys模板和logging模块获取行号和函数名的方法

python在linux中输出带颜色的文字的方法

pydev使用wxpython找不到路径的解决方法

Python转码问题的解决方法

python读写文件操作示例程序

python 实现归并排序算法

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

python读取注册表中值的方法

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

精品推荐
分类导航