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

Резултати

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

Пребарај: #companies

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

@balinews · Post #261 · 12.12.2024 г., 13:45

🏭Manufacturer of Smirnoff, Captain Morgan and Guiness expands production in Bali 📰 One of the world's largest producers of alcoholic beverages, the British company Diageo, is expanding its production in Bali. 8,800 m² of production capacity will be added to the existing factory in the Tabanan area. 🗺 Diageo is the owner of such global brands as Captain Morgan rum, Johnnie Walker whisky, Smirnoff vodka and Guinness beer. The company is betting on increasing sales not only in Indonesia but in the entire Southeast Asian region. ↗️ The factory has been operating in Bali since 2014, and products have been exported to other Southeast Asian countries since 2021. According to Diageo representatives, this region accounts for 19% of total sales. 🎯 The company has big plans for the renovated plant. Bali's strategic location makes it a convenient center for a production hub not only for Southeast Asia, but also for the entire Asia-Pacific region. @BaliNews #companies#business

Venture Village Wall 🦄

@venturevillagewall · Post #4320 · 06.03.2025 г., 10:00

Tether Freezes Garantex USDT Accounts ⚠️ Tether has frozen Garantex's USDT accounts worth over 2.5 billion rubles, forcing the exchange to suspend all services, including crypto withdrawals. Read more: hashtelegraph.com 💵 In other news, OpenAI plans to charge up to $20,000 per month for specialized AI agents aimed at various sectors. Details: forklog.com 💰 The global venture capital funding dropped to $19 billion in February, with AI startups receiving 30% of investments. Source: Crunchbase #Tether#Garantex#USDT#AI#Crypto#VC#Solana#Cardano#Canoo#companies#startups#funding#blockchain#fintech#venturecapital#innovation#technology#analytics#automotive#delivery#robotics