首页 > TAG信息列表 > replist
Python技巧-实现批量替换字符串
场景一 · 批量将不同的字符串替换为不同内容 # 要替换的内容 key-value replist = {"1":"一","2":"二","3":"三"} txt = "111-222-333-112233-123" def dl(t: str, repl: dict): for i in repl: t = t.replace(i,repl[i]) retPython技巧-实现批量替换字符串
场景一 · 批量将不同的字符串替换为不同内容 # 要替换的内容 key-value replist = {"1":"一","2":"二","3":"三"} txt = "111-222-333-112233-123" def dl(t: str, repl: dict): for i in repl: t = t.replace(i,repl[i]) ret