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

Резултати

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

Пребарај: #collab

当前筛选 #collab清除筛选
TON Map News

@thetonmap · Post #115 · 29.06.2024 г., 18:30

🤩 TON Map #collab with MUSK! The MUSK team announced a P2E game where you can earn the $MUSK token. The project website features a roadmap and all the essential information. In the bot, you can already start earning tokens by completing tasks and simply receiving them every 12 hours! 🚀 Not a financial advice - DYOR ❤️ TON Map App | X | Fam chat | Map

Hashtags

Go! Announcements

@gorwachain_announcements · Post #175 · 23.06.2023 г., 16:35

New Collab Alert! 🚨 Are you up for some healthy competition? We have partnered with Genopets for a highly rewarding healthy challenge with a $2000 prize pool! 🤯 How To Enter: 1️⃣ Sign up to Health Hero and Genopets by 6/29 at 11:59 PM PT (Use code "healthhero" on Genopets) 2️⃣ Follow both @Genopets & @Gohealthhero on Twitter 3️⃣ Like and retweet this competition's post on Twitter 4️⃣ Reply to the competition tweet thread with a photo of your Genopet 🏆 20 players will win part of a $2,000 prize pool - each winner gets $50 worth of $HLTHY and $50 worth of $GENE, plus their Go!Bot NFT. Remember, with Health Hero you can unlock up to 50% cash back on healthy purchases and health benefits such as global telehealth and mental health. Stay active with your Genopet, get health rewards with Health Hero 🤝 #web3#collab#genopets#health#wellness#p2e#m2e

Desi Memes Funny Jokes

@DESI_MEMES_Funny_Jokes · Post #5858 · 22.11.2024 г., 13:03

Crorepati to roadpati🥲😭 #gym#relatable#collab#new#gambling#aviator#game#money#dad#son#funny#content#comedy#trend#viral#explore#fypppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp