0
点赞
收藏
分享

微信扫一扫

类型别名TypeAlias

纽二 2023-10-23 阅读 43

from collections.abc import Iterable
from typing import TypeAlias

FromTo = tuple[str, str]  # 3.10之前
FromTo: TypeAlias = tuple[str, str] # 3.10之后推荐使用TypeAlias


def zip_replace(text: str, changes: Iterable[FromTo]) -> str:
    for from_, to in changes:
        text = text.replace(from_, to)
    return text

-------------------------------------------

个性签名:代码过万,键盘敲烂!!!

举报

相关推荐

0 条评论