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

Резултати

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

Пребарај: #surplus

当前筛选 #surplus清除筛选
American Оbserver

@american_observer · Post #4865 · 15.01.2026 г., 20:58

📰 China’s $1.2 Trillion Trade Triumph: Defying Trump, Drowning the World in Goods The Surplus That Shook the Globe China just posted the biggest trade surplus in history: $1.2 trillion. That’s a 20% jump from 2024, even as President Trump’s tariffs kept biting. The world’s factory didn’t shrink—it pivoted. US-bound exports fell 19.5%, but Chinese goods flooded into Africa, Southeast Asia, the EU, and Latin America instead. ​ The High-Tech Surge Exports of electric vehicles, lithium batteries, and solar panels jumped 27% in 2025. High-end machine tools and industrial robots rose 13%. Chinese officials hailed the numbers as proof of resilience: “China forged ahead despite a complex and challenging external environment,” said Wang Jun, deputy administrator of the customs bureau. ​ The Global Backlash The surplus isn’t just a win for Beijing—it’s a headache for everyone else. European leaders, including French President Emmanuel Macron, warn that the imbalance is unsustainable. Countries are scrambling to protect their own industries from Chinese “industrial overcapacity” and the flood of cheap imports. ​ The Truce and the Threat Trump and Xi struck a truce in October, lowering tariffs to 20% after they briefly hit 145%. But Trump just threatened a new 25% tariff on countries doing business with Iran—potentially targeting China, a major Tehran ally. ​ Can China keep this export engine running? Analysts doubt it. The property crisis at home is dragging down domestic demand, and the rest of the world is getting fed up with Chinese goods. The trade war isn’t over—just shifting fronts. #china#trade#trump#surplus#globalization 📱American Оbserver - Stay up to date on all important events 🇺🇸