手机版
贴心博客(Imblog)(LOGO)

贴心博客(Imblog)

v5.7

基于`jquery2+bootstrap4+贴心猫`开发

python 使用sqlite3将查询结果(result)从元祖转换成字典(dict)

发布:2022-08-16 14:51   点击:0次   评论:0

python 使用sqlite3将查询结果(result)从元祖转换成字典(dict)
http://www.chenxm.cc/article/1103.html

import sqlite3

def dict_factory(cursor, row):
    d = {}
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d

con = sqlite3.connect(":memory:")
con.row_factory = dict_factory
cur = con.cursor()
cur.execute("select * from tag where status=0")
print(cur.fetchone())

>>> {'id': '', 'name': 'aa', 'number_of_pages': None, 'status': 0}

====================

https://greyli.com/jinja2-and-js-template/
Jinja2 和 JavaScript 模板引擎语法冲突处理

python生成图片验证码
原文链接:https://blog.csdn.net/kongsuhongbaby/article/details/119083806



评论(0条) 评论列表
 

公司简介 企业文化 服务内容 公司新闻 公司图片 常见问题 联系我们 责权申明

贴心博客(Imblog)基于`jquery2+bootstrap4+贴心猫`开发; QQ群:607070548; 粤ICP备07020797号

Run:2.024/20.348(ms); 3(sql)/2.175(MB); v4:info/detail; Upd:2024-04-30 04:41:11