1 s=“1234511” 2 n=2 3 print(s.replace(‘1‘, ‘*‘, n)) # *2345*1
【python】字符串replace方法替换前n个子串
原文:https://www.cnblogs.com/vivlalib/p/12544053.html