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

Резултати

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

Пребарај: #tensions

当前筛选 #tensions清除筛选
Crypto M - Crypto News

@CryptoM · Post #65353 · 13.04.2026 г., 02:04

🚀 Iranian Official Warns of Potential Response to U.S. Naval Blockade An Iranian official has issued a warning regarding Iran's potential response to a U.S. naval blockade. According to NS3.AI, the official indicated that Iran possesses an unused strategy that could be employed if tensions escalate further. This statement comes amid ongoing geopolitical tensions between the two nations, highlighting the complex dynamics at play in the region. #Iran#US#NavalBlockade#Geopolitics#Tensions#Strategy#MiddleEast

Crypto M - Crypto News

@CryptoM · Post #65095 · 11.04.2026 г., 00:45

🚀 Lebanon and Israel to Hold First Meeting on Ceasefire Talks Lebanon and Israel have agreed to hold their first meeting on Tuesday at the U.S. State Department to discuss a ceasefire and set a date for negotiations. According to BlockBeats, this development marks a significant step towards addressing ongoing tensions between the two nations. #Lebanon#Israel#Ceasefire#Negotiations#USStateDepartment#Tensions

Crypto M - Crypto News

@CryptoM · Post #65350 · 13.04.2026 г., 01:55

🚀 U.S. and Iran Maintain Temporary Ceasefire Amid Tensions U.S. President Donald Trump announced that the temporary two-week ceasefire between the United States and Iran is "generally holding well." According to Odaily, this statement comes despite the lack of progress in marathon negotiations held over the weekend in Pakistan. Trump, speaking to reporters upon his return to Washington from Florida, stated, "I think it's generally holding well. Their military has been destroyed. Their entire navy is at the bottom of the sea." He also mentioned that the U.S. would begin a blockade of the Strait of Hormuz at 10 a.m. Eastern Time on Monday. Additionally, Trump noted that two American soldiers rescued in Iran earlier this month are currently in good condition. #US#Iran#Ceasefire#Tensions#Trump#Military#Negotiations#StraitOfHormuz

Crypto M - Crypto News

@CryptoM · Post #65018 · 10.04.2026 г., 14:06

🚀 Iranian Military Maintains High Alert Amid U.S. and Israeli Tensions On April 10, the Iranian Armed Forces announced that they remain on high alert, ready to engage if necessary. According to BlockBeats, a spokesperson from the Khatam al-Anbiya Central Headquarters stated that this stance is due to repeated breaches of trust by the United States and Israel. The statement underscores ongoing tensions in the region, highlighting Iran's preparedness to respond to perceived threats. #Iran#Military#US#Israel#Tensions#MiddleEast#Alert

Crypto M - Crypto News

@CryptoM · Post #65401 · 13.04.2026 г., 05:15

🚀 U.S. to Impose Blockade on Iranian Ports Amid Tensions U.S. President Donald Trump announced on his social media platform that the United States will enforce a blockade on ships entering and exiting Iranian ports at 10 a.m. Eastern Time on April 13. According to BlockBeats, this decision follows unsuccessful negotiations between the United States and Iran. On April 12, President Trump expressed indifference towards Iran's willingness to return to the negotiating table. He reiterated the plan to impose the blockade and voiced disappointment over NATO's lack of support for the U.S. in the conflict involving Iran. #US#Iran#blockade#Trump#NATO#tensions#MiddleEast#sanctions#diplomacy

Crypto M - Crypto News

@CryptoM · Post #65141 · 11.04.2026 г., 11:36

🚀 Russia and Ukraine Conduct Prisoner Swap Mediated by UAE Russia and Ukraine have successfully exchanged 175 prisoners of war, with the United Arab Emirates playing a mediating role in the process. Bloomberg posted on X, highlighting the significance of this exchange amid ongoing tensions between the two nations. The swap marks a notable development in the efforts to address humanitarian concerns arising from the conflict. Both countries have been engaged in a prolonged conflict, and such exchanges are seen as steps towards easing tensions and addressing the humanitarian impact of the war. The involvement of the UAE underscores the international community's interest in facilitating dialogue and resolution between Russia and Ukraine. This exchange is part of ongoing efforts to manage the humanitarian aspects of the conflict, which has drawn widespread international attention. #Russia#Ukraine#PrisonerSwap#UAE#HumanitarianEfforts#ConflictResolution#InternationalDiplomacy#HumanitarianImpact#Tensions#War