Mass string replace in python?

前端 未结 13 2106
我寻月下人不归
我寻月下人不归 2020-11-28 20:14

Say I have a string that looks like this:

str = \"The &yquick &cbrown &bfox &Yjumps over the &ulazy dog\"

You\'ll notic

13条回答
  •  有刺的猬
    2020-11-28 20:55

    Not sure about the speed of this solution either, but you could just loop through your dictionary and repeatedly call the built-in

    str.replace(old, new)

    This might perform decently well if the original string isn't too long, but it would obviously suffer as the string got longer.

提交回复
热议问题