python從sqlite讀取并顯示數據的方法
更新時間:2015年05月08日 12:16:53 作者:work24
這篇文章主要介紹了python從sqlite讀取并顯示數據的方法,涉及Python操作SQLite數據庫的讀取及顯示相關技巧,需要的朋友可以參考下
本文實例講述了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.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程序設計有所幫助。
相關文章
Python3使用騰訊云文字識別(騰訊OCR)提取圖片中的文字內容實例詳解
這篇文章主要介紹了Python3使用騰訊云文字識別(騰訊OCR)提取圖片中的文字內容方法詳解,需要的朋友可以參考下2020-02-02對pytorch中x = x.view(x.size(0), -1) 的理解說明
這篇文章主要介紹了對pytorch中x = x.view(x.size(0), -1) 的理解說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-03-03詳解Tensorflow數據讀取有三種方式(next_batch)
本篇文章主要介紹了Tensorflow數據讀取有三種方式(next_batch),小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-02-02