隐藏页面特效

11 2021 档案

摘要:# 信号的理解 在某个行为进行的某个阶段给这个行为添加一个附带的行为 # 相关api ## 数据表 pre_init # django的model执行其构造方法前,自动触发 post_init # django的model执行其构造方法后,自动触发 pre_save # djangod的model对 阅读全文 »
posted @ 2021-11-26 18:05 我在路上回头看 阅读(32) 评论(0) 推荐(0) 编辑
摘要:# _meta组件是一个django中任何一个model类的类实例用来自省的api,简单点说,比如有一个Accounts的模型,则 Accounts._meta # 常用接口 model.Userinfo._meta.app_label # 获取该类所在app的app名称 model.Userinf 阅读全文 »
posted @ 2021-11-26 16:37 我在路上回头看 阅读(45) 评论(0) 推荐(0) 编辑
摘要:# 主要用法就是调用django自定义的Command命令 # 语法 django.core.management.call_command(name,*args,**options) - name # 要调用的命令的名称或命令对象。除非测试需要对象,否则首选传递自定义command的文件名称。 - 阅读全文 »
posted @ 2021-11-26 14:39 我在路上回头看 阅读(506) 评论(0) 推荐(0) 编辑
摘要:# attr可以简单理解为namedtuple的增强版 import attr @attr.s class Point(object): x = attr.ib(default=1) # 定义默认参数 y = attr.ib(kw_only=True) # 关键字参数 p1 = Point(1, y 阅读全文 »
posted @ 2021-11-22 15:52 我在路上回头看 阅读(609) 评论(0) 推荐(0) 编辑
摘要:# 示例 import fcntl with open('./test.txt', 'w') as f: fcntl.flock(f, fcntl.LOCK_EX) # 对文件加锁,除加锁进程外其它进程没有对已加锁文件读写访问权限 # fcntl.flock(f, fcntl.LOCK_UN) # 阅读全文 »
posted @ 2021-11-22 15:51 我在路上回头看 阅读(590) 评论(0) 推荐(0) 编辑
摘要:from string import Template s = Template('$who 在 $do') ts = s.substitute(who="张三", do="赏花") print(ts) # 模板s中默认以$标识需要替换的变量,在substitute以键值对的格式定义替换变量的值,并 阅读全文 »
posted @ 2021-11-22 15:51 我在路上回头看 阅读(314) 评论(0) 推荐(0) 编辑
摘要:枚举是与多个唯一常量值绑定的一组符号(即成员)。枚举中的成员可以进行身份比较,并且枚举自身也可迭代。 枚举成员名称建议使用大写字母 # 示例 from enum import Enum,unique, IntEnum(支持成员比较) @unique # unique装饰器确保属性名和值唯一 clas 阅读全文 »
posted @ 2021-11-22 15:50 我在路上回头看 阅读(258) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示