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
类型别名TypeAlias
发布时间 2023-08-28 08:48:28作者: 我在路上回头看