我的意思是,我想替换str[9:11]另一个字符串.如果我这样做str.replace(str[9:11], "###")它不起作用,因为序列[9:11]可以不止一次.如果str是"cdabcjkewabcef"我会得到"cd###jkew###ef"但我只想替换第二个.
str[9:11]
str.replace(str[9:11], "###")
"cdabcjkewabcef"
"cd###jkew###ef"
python string python-3.x
python ×1
python-3.x ×1
string ×1