Как применять функцию replace() к строкам в Python? Метод replace() в Python.

Pubblicato il: 04 luglio 2020
sul canale di: Olga Soboleva
1,686
41

#pythonпорусски #функцияreplace #методreplace #строкивpython

Упражнения:

1. Замените maturing sun на waning moon в данной строке:

p = 'Season of mists and mellow fruitfulness, close bosom-friend of the maturing sun'

2. Замените все буквы n буквой W в данной строке:

p = 'Season of mists and mellow fruitfulness, close bosom-friend of the maturing sun'

3. Замените king's на queen's в данной строке:

hd = 'All the king's horses and all the king's men couldn't put Humpty together again'

3. Замените все пробелы восклицательными знаками в данной строке:

hd = 'All the king's horses and all the king's men couldn't put Humpty together again'

______________________________________________________________________________________

Метод replace() это функция, которая ищет и заменяет любой символ или фрагмент строки.

Пример:

s = 'Beleet parus odinokiy'

Заменяем:

Beleet на Krasneet
Beleet parus на On
odinokiy на v tumane morya
e на X
Все пробелы на @

Курс №2 по программированию на Python 7
Python course in Russian
Курс по программированию на Питоне


In questa pagina del sito puoi guardare il video online Как применять функцию replace() к строкам в Python? Метод replace() в Python. della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Olga Soboleva 04 luglio 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,686 volte e gli è piaciuto 41 spettatori. Buona visione!