05 2024 档案
摘要:迭代器和生成器都可以用来遍历数据集合,但它们在实现上略有不同。下面是关于迭代器和生成器的一些简要介绍: 迭代器(Iterator): 迭代器是一种对象,用于表示一个数据流。它可以用来遍历容器内的元素,如列表、集合、字典等。迭代器通常有两个方法:__iter__和__next__。__iter__方法
阅读全文
摘要:装饰器 基本样式 def decorator(func): def wrapper(*args, **kwargs): print("before") res = func(*args, **kwargs) print("after") return res return wrapper @deco
阅读全文
摘要:收集静态文件 python manage.py collectstatic 安装django: pip install django 安装依赖 pip install -r requirements.txt 创建项目: django-admin startproject project_name 创
阅读全文
摘要:雷池WAF 社区版 | 下一代 Web 应用防火墙 | 免费使用 https://waf-ce.chaitin.cn/docs/guide/install https://www.chaitin.cn/zh/safeline
阅读全文
摘要:作 者:刘润 来 源:刘润(ID:runliu-pub) 如果我也出生于96年,年入10个亿…就好了。 可惜,我不是。但有人是。 第一次看到那位96年出生,但已经年入10个亿的创业者时,我有很多话想问。 有些,是关于:96年出生?比我小了整整20岁?哎,年轻真好!想当年我......嗯,还好,我打住
阅读全文
摘要:提取目录 import markdown from markdown.extensions.toc import TocExtension def content(request, content_id): content_id = int(content_id) content = Content
阅读全文
摘要:一、安装markdown插件 pip install django-mdeditor pip install markdown 二、在 settings 配置文件 INSTALLED_APPS 中添加 mdeditor: INSTALLED_APPS = [ ... 'mdeditor', ] 三、
阅读全文
摘要:类的特殊方法 call 假设我们有一个类Calculator,它有一个__call__方法,用来计算两个数的和。代码如下: class Calculator: def __call__(self, a, b): return a + b calc = Calculator() result = ca
阅读全文