上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 51 下一页
摘要: 安装 brew install openssl 使用 root@MACdeMBP rem_key # openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 Generating a 4096 bit RS 阅读全文
posted @ 2023-10-04 13:18 我在路上回头看 阅读(74) 评论(0) 推荐(0) 编辑
摘要: ```python __init_subclass__ 是 Python 3.6 引入的一个特殊方法,用于在子类被定义时执行一些操作。 这个方法允许你在父类中定义一个类方法,当子类继承父类时会自动调用这个方法,你可以在其中进行一些初始化工作。 以下是关于 __init_subclass__ 方法的一 阅读全文
posted @ 2023-08-30 10:38 我在路上回头看 阅读(30) 评论(0) 推荐(0) 编辑
摘要: ```python def quantity(storage_name): def qty_getter(instance): return instance.__dict__[storage_name] def qty_setter(instance,value): if value > 0: i 阅读全文
posted @ 2023-08-30 08:48 我在路上回头看 阅读(11) 评论(0) 推荐(0) 编辑
摘要: ```python from typing import TypeVar, Generic class Beverage: ❶ """任何饮料""" class Juice(Beverage): """任何果汁""" class OrangeJuice(Juice): """使用巴西橙子制作的美味果 阅读全文
posted @ 2023-08-29 15:35 我在路上回头看 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 在 Python 的 typing 模块中,Generic 是一个泛型类,用于创建参数化的类和函数,以便支持不同类型的参数。它允许你定义具有类型参数的类,这些类型参数在实例化时才确定。这样,你可以在不同的上下文中使用相同的类,但可以使用不同的类型参数。 使用 Generic 可以增强代码的可重用性和 阅读全文
posted @ 2023-08-29 14:56 我在路上回头看 阅读(193) 评论(0) 推荐(0) 编辑
摘要: ```python 在 PyCharm 中,你可以通过以下步骤实现这一目标: 打开 PyCharm,点击顶部菜单的 "File"(文件) -> "Settings"(设置)。 在弹出的窗口中,选择 "Editor"(编辑器) -> "Live Templates"(代码模板)。 在左侧的列表中,选择 阅读全文
posted @ 2023-08-28 12:10 我在路上回头看 阅读(206) 评论(0) 推荐(0) 编辑
摘要: from collections.abc import Callable """ Callable[[ParamType1, ParamType2], ReturnType] [参数1类型,参数2类型], 返回值类型 Callable[[], int] 是 Callable[[], float] 的 阅读全文
posted @ 2023-08-28 11:05 我在路上回头看 阅读(37) 评论(0) 推荐(0) 编辑
摘要: ```python from collections.abc import Iterable from typing import TypeAlias FromTo = tuple[str, str] # 3.10之前 FromTo: TypeAlias = tuple[str, str] # 3. 阅读全文
posted @ 2023-08-28 08:44 我在路上回头看 阅读(14) 评论(0) 推荐(0) 编辑
摘要: # 生产者代码 ```python # -*- coding: utf-8 -*- # pylint: disable=C0111,C0103,R0205 import json import pika from pika.exchange_type import ExchangeType prin 阅读全文
posted @ 2023-08-18 02:00 我在路上回头看 阅读(34) 评论(0) 推荐(0) 编辑
摘要: # 代码 ```python from inspect import signature from functools import wraps def typeassert(*ty_args, **ty_kwargs): def decorate(func): if not __debug__: 阅读全文
posted @ 2023-07-11 08:57 我在路上回头看 阅读(14) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 51 下一页