TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

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

Резултати

Пронајдени 31 слични објави

Пребарај: #modern

当前筛选 #modern清除筛选
Pensive|

@PensivePost · Post #5398 · 16.09.2021 г., 18:41

Withering soul Little by little she dies everyday Demons everywhere she's losing her sight Pain has reached her bones Breathing freely is a luxury now she resists but she knows she is a withering soul she is screaming but can anyone hear her? The world's gone deaf All eyes are shut, no one sees what's right in front of them She is not the only one She won't be the last one Time is a flat circle, Nietzsche said Once upon a time humans came into this world, cursed to repeat their doings time and time and time again Fading souls don't await the eternal rest There is no rest, there is no end to their agony Trapped they are, born prisoners Freedom was never a dream only an illusion #review #modern#poetry

Luxury Lifestyle

@luxury_lifestyle_billionaire_hub · Post #6611 · 19.03.2020 г., 03:01

🌈Modern Mansion 😍 listed at $7,995,000 #Luxury#Modern#Mansion 📷 Ig @hiltonhyland 💁Via @TheLuxuryClub ✔️🔜@R_Group_Official ━━━━━━━━━━━━━━━━━

Luxury Lifestyle

@luxury_lifestyle_billionaire_hub · Post #6549 · 06.02.2020 г., 03:27

🌈Bayfront Estate Listed at $16,900,000 #Luxury#Modern#Mansion 📷IG@MatthewDugow 💁Via @TheLuxuryClub ✔️🔜@R_Group_Official ━━━━━━━━━━━━━━━━━

Luxury Lifestyle

@luxury_lifestyle_billionaire_hub · Post #6516 · 29.01.2020 г., 03:21

🌈Modern Mansion 😍 Goals #Luxury#Modern#Mansion 📷IG@coldwellbanker_beverlyhills 💁Via @TheLuxuryClub ✔️🔜@R_Group_Official ━━━━━━━━━━━━━━━━━

Luxury Lifestyle

@luxury_lifestyle_billionaire_hub · Post #6448 · 25.11.2019 г., 03:20

🌈Modern 😍 Mansion #Luxury#Modern#Mansion 📷udesignmarbella/ 💁Via @TheLuxuryClub ✔️🔜@R_Group_Official ━━━━━━━━━━━━━━━━━

Luxury Lifestyle

@luxury_lifestyle_billionaire_hub · Post #6444 · 21.11.2019 г., 08:33

🌈SOLD❤️ for $10,000,000. (CAN) - Located in West Vancouver Canada. #Luxury#Modern#Mansion 📷Listed By malcolmhasman 💁Via @TheLuxuryClub ✔️🔜@R_Group_Official ━━━━━━━━━━━━━━━━━

Luxury Lifestyle

@luxury_lifestyle_billionaire_hub · Post #6442 · 19.11.2019 г., 02:42

🌈Contemporary style Modern Mansion #Luxury#Modern#Mansion 📷udesignmarbella/ 💁Via @TheLuxuryClub ✔️🔜@R_Group_Official ━━━━━━━━━━━━━━━━━

Luxury Lifestyle

@luxury_lifestyle_billionaire_hub · Post #6431 · 15.11.2019 г., 02:35

🌈Love this new 😍 modern mansion design at Cala Vinyas, Mallorca. #Luxury#Modern#Mansion 💁Via @TheLuxuryClub ✔️🔜@R_Group_Official ━━━━━━━━━━━━━━━━━

ПретходнаСтраница 1 од 3Следна