Как применять функцию replace() к строкам в Python? Метод replace() в Python.
#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
Курс по программированию на Питоне
Видео Как применять функцию replace() к строкам в Python? Метод replace() в Python. канала Olga Soboleva
Упражнения:
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
Курс по программированию на Питоне
Видео Как применять функцию replace() к строкам в Python? Метод replace() в Python. канала Olga Soboleva
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Filtering in a loop: example + exercise 3](https://i.ytimg.com/vi/7IKC4prx9CM/default.jpg)
![Grundkonzepte der Programmiersprache Python](https://i.ytimg.com/vi/vzJFXiDaBWA/default.jpg)
![Summing elements in a list using a loop "for" in Python: example + exercise 6](https://i.ytimg.com/vi/ZL75f3jqsAs/default.jpg)
![Konditionale Schritte in Python: Aufgabe 5](https://i.ytimg.com/vi/QbFLe2f1Nc8/default.jpg)
![Buscamos el valor mayor en una lista usando la palabra clave None en Python: ejemplo + ejercicio 11](https://i.ytimg.com/vi/nydOjKo28VU/default.jpg)
![Порядок выполнения действий в программировании и математике](https://i.ytimg.com/vi/6BQNYYHYGjA/default.jpg)
![Palabra clave "in" en Python. ¿Cómo aplicar "in" a strings en Python?](https://i.ytimg.com/vi/Ah_iaC8w6pA/default.jpg)
![Order of operations in programming and mathematics](https://i.ytimg.com/vi/8KVWbptzwj4/default.jpg)
![Counting elements in a list using a for loop in Python: example + exercise 5](https://i.ytimg.com/vi/vtS12NIoAWU/default.jpg)
![Конструкция try and except в Python: пример 2 - заработок за неделю](https://i.ytimg.com/vi/XFRmoFgGFx4/default.jpg)
![Structure "try and except" in Python: exercise 1 - a hotel](https://i.ytimg.com/vi/jltzq6YUpf0/default.jpg)
![Creación del bucle "for" en Python](https://i.ytimg.com/vi/j-24VLm1HAE/default.jpg)
![Упражнения на циклы в Python - проверьте себя](https://i.ytimg.com/vi/BK_LsClDm1Q/default.jpg)
![Python: la estructura del curso número 1](https://i.ytimg.com/vi/x63Ic81f6xM/default.jpg)
![Strings in Python. String concatenation in Python.](https://i.ytimg.com/vi/HbrGRoD0Uww/default.jpg)
![Python: Struktur des Kurses Nummer 1](https://i.ytimg.com/vi/Y8ZRyG9no2k/default.jpg)
![Индексы в строках в Python: оператор индексации [ ]](https://i.ytimg.com/vi/t_KpQr7MXxI/default.jpg)
![Variablen in Python](https://i.ytimg.com/vi/of1DqlZ6_UY/default.jpg)
![Bauen eigene Funktionen in Python: die Übung "Die Punktezahl und die Note"](https://i.ytimg.com/vi/I10mUBJCOK8/default.jpg)
![Johann Sebastian Bach: Sinfonia No. 4 in D Minor (BWV 790), celesta sound](https://i.ytimg.com/vi/SeCViPj1XtM/default.jpg)
![Como abrir y leer ficheros en Python](https://i.ytimg.com/vi/OsapBqsvLgU/default.jpg)