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