从左到右替换 python

def rreplace(string,str,new_str,max=1):
    string=string[::-1]
    str=str[::-1]
    new_str=new_str[::-1]
    return string.replace(str,new_str,max)[::-1]

posted @ 2020-07-31 11:37  得淼  阅读(232)  评论(0编辑  收藏  举报