在 Python 中使用 string.replace()
a = "This is the island of istanbul"
print (a.replace("is" , "was", 1))
print (a.replace("is" , "was", 2))
print (a.replace("is" , "was"))
Output:
Thwas is the island of istanbul
Thwas was the island of istanbul
Thwas was the wasland of wastanbul