← Retour à la référence Python

()

Module : str

Remplace toutes les occurrences d'une sous-chaîne par une autre.

📝 Syntaxe

str.replace(old, new, count=-1)

💡 Exemples

'hello world'.replace('world', 'Python')
'hello Python'
'a a a'.replace('a', 'b', 2)
'b b a'
EdTech AI