首页 > 其他 > 详细

平时记录

时间:2019-05-21 11:32:03      阅读:117      评论:0      收藏:0      [点我收藏+]

1.生成器不能直接切片

2.  django中使用原生sql

     from django.db import  connection

     cursor = connection.cursor()

     cursor.execute("select * from xx where id=1")

     row = cursor.fetchone()

 

     users = User.objects.raw("select * from user where name=‘xx‘")

     for user in users:

            print(user.name)

   查询结果对应model

3. sql 使用正则

select * from user where name regexp ‘a|b‘;

4.python使用 推导式 比 函数要快的多

list()           []

tuple()       ()

dict()         {}

 

平时记录

原文:https://www.cnblogs.com/wayland3/p/10898594.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!