@doniyorieltss · Post #2131 · 30.08.2024 г., 14:35
When you dream up your perfect life, you think about how you're seen, rather than what your daily tasks include 101 essays that will change the way you think #insights
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #309 · 2 фев.
Метод строки split() разделяет строку на несколько строк по указанному символу >>> "a_b_c".split('_') ['a', 'b', 'c'] Можно указать максимальное количество разделений >>> "a_b_c".split('_', 1) ['a', 'b_c'] Или резать с другой стороны с помощью rsplit() (right split) >>> "a_b_c".rsplit('_', 1) ['a_b', 'c'] А что будет если оставить аргументы пустыми? >>> "a_b_c".split() ['a_b_c'] Получаем список с одним элементом, потому что по умолчанию используется пробельный символ. >>> "a b c".split() ['a', 'b', 'c'] То есть это равнозначно такому вызову? >>> "a b c".split(" ") ['a', 'b', 'c'] Кажется да, но нет! Давайте попробуем добавить пробелов между буквами >>> "a b c".split(" ") ['a', '', '', 'b', '', '', 'c'] И вот картина уже не так предсказуема 😕 А вот что будет по умолчанию >>> "a b c".split() ['a', 'b', 'c'] Всё снова красиво! 🤩 По умолчанию в качестве разделителя используется любой пробельный символ, будь то табуляция или новая строка. Включая несколько таких символов идущих подряд. А также игнорируются пробельные символы по краям строки. >>> "a\t b\n c ".split() ['a', 'b', 'c'] Аналогичный способ можно собрать с помощью регулярного выражения. Но пробелы по краям строки придется обрабатывать дополнительно. >>> import re >>> re.split(r"\s+", ' a b c '.strip()) ['a', 'b', 'c'] Здесь тоже можно указать количество разделений >>> re.split(r"\s+", 'a b c', 1) ['a', 'b c'] А что если мы хотим написать красиво, то есть split() без аргументов, но при этом указать количество разделений? В этом случае первым аргументом передаём None >>> "a\n b c".split(None, 1) ['a', 'b c'] Данный метод не учитывает строки с пробелами, взятые в кавычки 'a "b c" '.split() ['a', '"b', 'c"'] Но для таких случаев есть другие способы. #tricks#basic
Пребарај: #insights
@doniyorieltss · Post #2131 · 30.08.2024 г., 14:35
When you dream up your perfect life, you think about how you're seen, rather than what your daily tasks include 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2130 · 29.08.2024 г., 14:35
You are more in love with ideas than you are with work and processes required to make them reality 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2126 · 28.08.2024 г., 14:35
If you don't know what to do, you don't know what's wrong. If you don't know what's wrong, it is because some part of you is resisting seeing it 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2125 · 19.08.2024 г., 14:36
Clarity comes from doing, not thinking about doing 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2124 · 18.08.2024 г., 14:35
The best things will not make sense - not initially, at least 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2123 · 17.08.2024 г., 14:35
To fully accept your life - the highs, lows, good, bad - is to be grateful for all of it, and to know that the "good" teaches you well, but the "bad" teaches you better 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2122 · 16.08.2024 г., 14:34
Sometimes the way light enters us is, in fact, through the wound 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2121 · 15.08.2024 г., 14:34
What you learn and who you become is more important than how you temporarily feel 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2120 · 14.08.2024 г., 14:34
The people who were able to hurt you most were also the people whom you were able to love the most 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2118 · 13.08.2024 г., 14:36
The road to hell was paved with good intentions 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2117 · 12.08.2024 г., 14:44
Defensiveness is born of fear; assertiveness is born of confidence 101 essays that will change the way you think #insights
Hashtags
@doniyorieltss · Post #2116 · 11.08.2024 г., 14:34
Life isn't about being "certain", it's about trying anyway 101 essays that will change the way you think #insights
Hashtags