1、
>>> a = "gooood" >>> a.replace("o","x") ## 将o全部替换为x 'gxxxxd' >>> a.replace("o","x",1) ## 指定替换次数 'gxoood' >>> a.replace("o","x",2) 'gxxood' >>> a.replace("o","x",3) 'gxxxod'