上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 51 下一页
摘要: ```python from calendar import month_abbr import re def change_date(m): mon_name = month_abbr[int(m.group(1))] return '{} {} {}'.format(m.group(2), mo 阅读全文
posted @ 2023-07-10 08:47 我在路上回头看 阅读(12) 评论(0) 推荐(0) 编辑
摘要: # 存入redis中的设计 ```python 商品库存 key: sk:prodid:qt string: 剩余个数 秒杀成功者清单 key: sk:prodid:user set: 成功者的user_id 成功者的user_id 成功者的user_id ``` # 代码实现 ```java pu 阅读全文
posted @ 2023-07-09 09:50 我在路上回头看 阅读(8) 评论(0) 推荐(0) 编辑
摘要: # 说明 ```python 在 Python 的 typing 模块中,Protocol 是一个用于定义协议(Protocol)的类。 协议是一种形式化的接口,定义了一组方法或属性的规范,而不关心具体的实现。Protocol 类提供了一种方式来定义这些协议。 使用 Protocol 类时,可以定义 阅读全文
posted @ 2023-06-25 03:50 我在路上回头看 阅读(755) 评论(0) 推荐(0) 编辑
摘要: 说明 Iterable、Container和Sized 每个容器都应该继承这三个抽象基类,或者实现兼容的协议。Iterable通过__iter__方法支持迭代, Container通过__contains__方法支持in运算符,Sized通过__len__方法支持len()函数。 Collectio 阅读全文
posted @ 2023-05-12 17:44 我在路上回头看 阅读(47) 评论(0) 推荐(0) 编辑
摘要: # 使用场景 ```python 在 Python 中,虚拟子类是一种使用 `collections.abc` 模块中的 `abc.ABCMeta.register()` 方法创建的特殊子类。 虚拟子类允许将一个类注册为抽象基类的子类,即使在实际继承关系中并没有直接的继承关系。 虚拟子类的使用场景如 阅读全文
posted @ 2023-05-12 16:51 我在路上回头看 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 引入为什么需要TypeVar PEP484的作者希望借助typing模块引入类型提示,不改动语言的其它部分。通过精巧的元编程技术,让类 支持[]运算不成问题。但是方括号内的T变量必须在某处定义,否则要大范围改动python解释器才能让泛型 支持特殊的[]表示法。鉴于此,我们增加了typing.Typ 阅读全文
posted @ 2023-05-12 12:17 我在路上回头看 阅读(681) 评论(0) 推荐(1) 编辑
摘要: ```python from typing import Optional def show_count(count: int, singular: str, plural: Optional[str] = None) -> str: Optional[str]表示plural的值可以是一个str或 阅读全文
posted @ 2023-05-10 23:30 我在路上回头看 阅读(26) 评论(0) 推荐(0) 编辑
摘要: package main import "fmt" type Sex int // 枚举 const ( SexMan Sex = iota SexWoman SexUnkonw ) func (s Sex) String() string{ switch s { case 0: return "男 阅读全文
posted @ 2023-05-05 02:07 我在路上回头看 阅读(36) 评论(0) 推荐(0) 编辑
摘要: # 方式1 a = [1,2,3] print(a) # 4551311680 a.extend([4,5]) print(a) # 4551311680 # 方式2 b = [1,2,3] print(b) # 4494299456 b += [4,5,6] print(b) # 44942994 阅读全文
posted @ 2023-05-03 23:39 我在路上回头看 阅读(20) 评论(0) 推荐(0) 编辑
摘要: goland版本:2020 go版本:1.20.3最新版 在goland中配置GOROOT时找不到sdk 解决版本: > cd /usr/local/go # 我本地go的安装目录 > cd /src/runtime/internal/sys > vi zversion.go package sys 阅读全文
posted @ 2023-04-18 02:11 我在路上回头看 阅读(737) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 51 下一页