摘要: class Foo(): def __str__(self): return "好好学习" def __getattr__(self, item): return "0000" def __setattr__(self, key, value): self.__dict__[key]=value def _... 阅读全文
posted @ 2018-11-09 10:56 CHVV 阅读(336) 评论(0) 推荐(0) 编辑
摘要: def test01(): print('你好呀') #执行函数 test01() #打印结果:你好呀 #带返回值的函数 def add(a, b): c = a + b return c ret = add(2,3) #打印函数的返回值 print(ret) #打印结果:5 class Foo(object): def func(self): ... 阅读全文
posted @ 2018-11-06 09:41 CHVV 阅读(707) 评论(0) 推荐(0) 编辑
摘要: python中的__name__ python中的__call__ 在Python中,__init__()函数的意义等同于类的构造器(同理,__del__()等同于类的析构函数)。因此,__init__()方法的作用是创建一个类的实例。 __call__()Python中的函数是一级对象。这意味着P 阅读全文
posted @ 2018-10-26 09:15 CHVV 阅读(1139) 评论(0) 推荐(0) 编辑
摘要: 一,第一种登录验证 二 第二种登录验证 装饰器版 三 第三种登录验证 before_request 阅读全文
posted @ 2018-10-25 17:14 CHVV 阅读(944) 评论(0) 推荐(0) 编辑
摘要: def auth(func): #func为被装饰的函数 def inner(*args,**kwargs): print("前") ret = func(*args,**kwargs) print("后") return ret return inner@authdef index(): print("index") ... 阅读全文
posted @ 2018-10-25 16:39 CHVV 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 通过一个内嵌类 "class Meta" 给你的 model 定义元数据, 类似下面这样: class Foo(models.Model): bar = models.CharField(maxlength=30) class Meta: # ... Model 元数据就是 "不是一个字段的任何数据 阅读全文
posted @ 2018-10-22 10:16 CHVV 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 本质设置响应头 由于浏览器存在同源策略机制,同源策略阻止从一个源加载的文档或脚本获取或设置另一个源加载的文档的属性。 特别的:由于同源策略是浏览器的限制,所以请求的发送和响应是可以进行,只不过浏览器不接受罢了。 浏览器同源策略并不是对所有的请求均制约: 制约: XmlHttpRequest 不叼:  阅读全文
posted @ 2018-10-19 10:08 CHVV 阅读(208) 评论(0) 推荐(1) 编辑
摘要: 1.自定义链接池 创建一个utils文件夹,并创建redis_pool.py文件 views.py 1 from django.shortcuts import HttpResponse 2 import redis 3 4 from utils.redis_pool import POOL 5 # 阅读全文
posted @ 2018-10-17 17:53 CHVV 阅读(221) 评论(0) 推荐(0) 编辑
摘要: python目录 python目录 1.字符串操作 2.encode,decode,str,bytes 3.文件的操作 4.字典列表 5.迭代器 6.生成器 7.列表生成式和生成器表达式 8.python的内置函数 9.正则表达式 10.计模式和单例模式__new__方法 11.装饰器 12.pyt 阅读全文
posted @ 2018-10-16 10:32 CHVV 阅读(304) 评论(0) 推荐(0) 编辑
摘要: models.py views.py urls.py 阅读全文
posted @ 2018-09-28 14:25 CHVV 阅读(356) 评论(0) 推荐(1) 编辑