字符串的多重替换:
(1)把str中出现的所有s1字符串替换为str2字符串:str.replace(s1,s2)
(2)把str中出现的所有s1,s2字符串分别替换为s3,s4字符串:str.replace(s1,s3) .replace(s2,s4)
(3)把str中出现的所有s1,s2字符串替换为s3字符串:酌情使用正则:import re; re.sub(“condition”,s3,str)
字符串的多重替换:(1)把str中出现的所有s1字符串替换为str2字符串:str.replace(s1,s2)
字符串的多重替换:
(1)把str中出现的所有s1字符串替换为str2字符串:str.replace(s1,s2)
(2)把str中出现的所有s1,s2字符串分别替换为s3,s4字符串:str.replace(s1,s3) .replace(s2,s4)
(3)把str中出现的所有s1,s2字符串替换为s3字符串:酌情使用正则:import re; re.sub(“condition”,s3,str)