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 слични објави

Пребарај: #jakarta

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

@balinews · Post #258 · 07.12.2024 г., 12:30

🇮🇩Jakarta will build an F1 track, a theme park and a new port 📰 One of the richest men in Indonesia, Sugianto Kusuma, is developing the PIK 2 city project in the north of Jakarta. The cost of the project is estimated at $16.5 billion. According to plans, the development will be complemented by Indonesia's first F1 track, a theme park and a seaport. 🏎 A few years ago in Bali already announced the construction of a theme park Paramount and Formula 1 track in the area of Jembran. But the work never started. 🏗 It is only good news about the new project PIK 2 as soon as the developers have a long-term vision and everything is going well with financing. @BaliNews #projects#business#Jakarta

Bali News

@balinews · Post #316 · 10.02.2025 г., 11:30

🏗Trump's project is stopped due to violations of environmental regulations 📰Bloomberg reports that the construction of a luxury Trump-branded golf resort owned by current US President Donald Trump has been suspended. Authorities accuse the developer of violating environmental regulations. 💬Indonesia's Environment Ministry issued a statement saying that the project of golf courses and branded residences 60 kilometers from Indonesia's capital Jakarta violates water drainage rules. The project is being developed by a development company owned by one of Indonesia's richest men, media tycoon Hary Tanoesoedibjo. @BaliNews #realestate#projects#Jakarta

Bali News

@balinews · Post #238 · 16.11.2024 г., 12:11

🎸Linkin Park will perform in Jakarta in early 2025 🎤 Linkin Park, the iconic alternative rock band, has finally started touring again. In 2024, after finally recovering from the loss of Chester Bennington, the band has added vocalist Emily Arsmstrong to their lineup. 📍Jakarta is the only city in Southeast Asia that the legendary band will visit. 📆 The concert will take place on February 16, 2025, Indonesia will be the fourth country the band will visit since the beginning of the tour, right after Brazil, Saudi Arabia, Mexico and Japan. 🎫Tickets for the show will be available from November 18 on the official website. Which venue Linkin park will perform at is not yet known. Keep an eye on the information as the best tickets for such concerts are sold out very quickly. @BaliNews #events#concerts#wheretogo#Jakarta