类型别名TypeAlias
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
-------------------------------------------
个性签名:代码过万,键盘敲烂!!!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!