摘要:
#tuple创建:元组名 = (20,) #特别注意一个的时候加,元组名 = (1, 2, 3)元组名 = 100,200,300元组名 = tuple(可迭代对象) 取值:变量=元组名[index]for item in 元组名 : xxx 元组没有推导式: t=(i for i in range 阅读全文
posted @ 2019-11-24 11:45
chenlulu1122
阅读(229)
评论(0)
推荐(0)
摘要:
#list 列表名.append(元素) 结尾加入元素列表.insert(索引,元素) 插入元素 列表名 = list(可迭代对象) 遍历可迭代对象加入list a=[1,2,3]b=['a','v']a+=bprint(a) [1, 2, 3, 'a', 'v']L.extend(lst) | 向 阅读全文
posted @ 2019-11-24 11:44
chenlulu1122
阅读(190)
评论(0)
推荐(0)
摘要:
#dict 创建d={'name':'ch','age':21} d={}d[name]='chen' d = [(1, 2)]c = dict(d)print(c) 可迭代对象d内部元素,必须是2个元素组成 修改字典名[键] = 数据键不存在,创建记录。键存在,修改值。 取数据: 变量 = 字典名 阅读全文
posted @ 2019-11-24 11:44
chenlulu1122
阅读(114)
评论(0)
推荐(0)
摘要:
#str 字符串格式化: 字符串%(变量)"我的名字是%s,年龄是%s" % (name, age) %s 字符串 %d整数 %f 浮点数 str内置函数: 判断isspace()如果字符串中只包含空白,则返回 True,否则返回 False.startswith(substr, beg=0,end 阅读全文
posted @ 2019-11-24 11:43
chenlulu1122
阅读(362)
评论(0)
推荐(0)
摘要:
# cookies 和 session ##cookies记录在客户端浏览器上的数据: 比如:1.通知浏览器保存数据,下次请求内容自带这些数据发给服务器from django.http import HttpResponse def index(request): resp = HttpRespon 阅读全文
posted @ 2019-11-24 10:58
chenlulu1122
阅读(134)
评论(0)
推荐(0)
摘要:
#django-admin后台管理 建立超级权限用户 python3 manage.py createsuperuser 后台管理的登录地址: - <http://127.0.0.1:8000/admin> ##自定义后台显示列表1.注册后台要显示的表 在app应用admin.py文件内 from 阅读全文
posted @ 2019-11-24 10:57
chenlulu1122
阅读(140)
评论(0)
推荐(0)
摘要:
#表关系 ##一对一创建from django.db import models class Author(models.Model): name = models.CharField('姓名', max_length=50) class Wife(models.Model): name = mod 阅读全文
posted @ 2019-11-24 10:57
chenlulu1122
阅读(108)
评论(0)
推荐(0)
摘要:
#聚合查询聚合:from django.db.models import * p=Book.objects.aggregate(avg_price=Avg('price')) 返回字典 p={avg_price:100} 聚合函数: - Sum, Avg, Count, Max, Min 分组聚合 阅读全文
posted @ 2019-11-24 10:56
chenlulu1122
阅读(91)
评论(0)
推荐(0)

浙公网安备 33010602011771号