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

Резултати

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

Пребарај: #parties

当前筛选 #parties清除筛选
Bali News

@balinews · Post #285 · 04.01.2025 г., 12:11

🪩Nick Fanciulli at Savaya Bali 📆 Sunday, 12 January Nic Fanciulli is a respected figure in electronic music, recognised for his Grammy-nominated remix of Gorillaz's ‘Dare’ and for founding the influential Saved Records label. His credits include projects such as The Social festival with top artists, as well as appearances at venues such as Space Ibiza and Tomorrowland, cementing his legacy in the dance music scene. 🔍 Details of the event, as well as tickets, are available on the official website. @BaliNews #wheretogo#events#parties

Bali News

@balinews · Post #230 · 29.10.2024 г., 03:07

🥳A four-day Halloween party in Kuta 🔔 Starting tomorrow, October 30, Old Man's will be hosting a series of Halloween parties starting at 5:00pm. Come dressed to impress as your favorite ghoul, ghost, or Halloween character for a chance to win big in our spine-chilling costume contest. 🎫 Tables for one-day start from Rp2,400,000 – included entrance fee for 4 pax, 1 bottle of house pouring and 4 mixers. 👨‍💻 More information via the link. @BaliNews #wheretogo#parties#Kuta

Bali News

@balinews · Post #434 · 12.06.2025 г., 14:04

🪩 There will be a party at Savaya on Saturday ℹ️ Building upon her cultural heritage and her musical tastes (the artist grew up listening to artists such as Nina Simone, Bob Marley and Marvin Gaye), AWEN started to produce her unique style of Afro-house. 🧞‍♀️ It mixed electronic instrumentation with timeless melodies - and a touch of spirituality. 📲 More info and tickets (Rp 600,000) are here. #wheretogo#parties#Badung@BaliNews

Bali News

@balinews · Post #383 · 06.04.2025 г., 13:50

⭐️Electronic music star Boris Brejcha in Bali 📍 Savaya Bali 📆 May 18, 2005 ⏰ Doors Open at 1:00 pm 🔞 Entry strictly 21+ 🎟 Rp1,350,000 🪩 German DJ Boris Brejcha is known to all lovers of techno and mind-blowing parties. As part of his world tour he will be stopping by Bali. 🔎 More information and tickets here. @BaliNews #events#parties#Badung

Bali News

@balinews · Post #335 · 27.02.2025 г., 12:16

🪩Morabito presents Bombossa Brothers 📍 Morabito Art Villa, Canggu 📅 Friday, February 28 ⏰ 6:00 pm Bombossa Brothers are twins with two interesting personalities and one mission: to entertain as many people as possible with their groovy melodic sound. Over the past couple of years, they have built up their reputation as a duo to watch by playing around the world and expanding their Momentum event series, hosting up to 2000 people in their hometown of Tallinn, Estonia. 🎫Tickets at the link from 250.000 IDR. @BaliNews #wheretogo#parties#Canggu