我想使用.replace函数来替换多个字符串.
我现在有
string.replace("condition1", "")
Run Code Online (Sandbox Code Playgroud)
但是想要有类似的东西
string.replace("condition1", "").replace("condition2", "text")
Run Code Online (Sandbox Code Playgroud)
虽然那感觉不是很好的语法
这样做的正确方法是什么?有点像grep/regex你可以做什么\1,\2并将字段替换为某些搜索字符串
对于Python 2.5,2.6,我应该使用string.replace还是re.sub基本的文本替换?
在PHP中,这是明确说明的,但我找不到类似的Python注释.