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

Published: 04 July 2020
on channel: 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
Курс по программированию на Питоне


On this page of the site you can watch the video online Как применять функцию replace() к строкам в Python? Метод replace() в Python. with a duration of hours minute second in good quality, which was uploaded by the user Olga Soboleva 04 July 2020, share the link with friends and acquaintances, this video has already been watched 1,686 times on youtube and it was liked by 41 viewers. Enjoy your viewing!