手机
当前位置:查字典教程网 >脚本专栏 >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连接sql server乱码的解决方法

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

python读取注册表中值的方法

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

Python中针对函数处理的特殊方法

python 字符串split的用法分享

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

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

Python的函数嵌套的使用方法

精品推荐
分类导航