Pour remplacer / supprimer un mot dans une phrase en python il existe la méthode replace. Exemple:
>>> s = 'Bonjour, comment ca va ?'>>> s = s.replace('Bonjour','Salut')>>> s'Salut, comment ca va ?'>>> s = s.replace('Salut','')>>> s', comment ca va ?'>>> s = 'Salut, comment ca va, Salut'>>> s = s.replace('Salut','')>>> s', comment ca va, '>>>
Recherches associées
| Liens | Site |
|---|---|
| string — Common string operations | Python Doc |
| Python String replace() Method | Tutorial Point |
| How to delete a character from a string using python? | stackoverflow |
| python string replace | stackoverflow |
| Python: replace characters in string | stackoverflow |
| Python replace function | stackoverflow |
| Python string.replace regular expression | stackoverflow |
| Python string.replace() not replacing characters | stackoverflow |
