标签:for div param range 替换字符串 def turn int replace
def replace_string(my_str, *args): """ 替换字符串 :param my_str: :param args: :return: """ print(args) length = len(args) for i in range(0, length-1, 2): new_str = my_str.replace(args[i], args[i+1]) return new_str def replace_string1(my_str, **kwargs): """ 替换字符串 :param my_str: :param kwargs: :return: """ print(kwargs) for key in kwargs: new_str = my_str.replace(key, kwargs[key]) return new_str print(replace_string("hello world", "l", "s", "o", "d")) print(replace_string1("hello world", l="s", o="d"))
标签:for div param range 替换字符串 def turn int replace
原文地址:https://www.cnblogs.com/sunBinary/p/10372406.html