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

Резултати

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

Пребарај: #olympics

当前筛选 #olympics清除筛选
Viral Today

@viral_today · Post #2963 · 02.09.2024 г., 10:30

Amazing close finish in the Paralympic 100m swim! Athletes are classified by functionality, so even with different impairments, like no hands or paralyzed legs, they compete on an even playing field. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2852 · 10.08.2024 г., 12:30

The first-ever Olympic breakdancing tournament is underway in Paris, and it’s already giving us some unforgettable moments. Australian dancer Rachael “Raygun” Gunn went viral for all the wrong reasons—her bizarre moves and headstands left everyone cringing. Gunn lost all three of her matches without scoring a single point. Safe to say, people are now questioning the decision to make breaking an Olympic sport. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2848 · 09.08.2024 г., 12:30

Speed in 1924 vs. 2024: How much faster is today's Olympic gold medalist compared to 100 years ago? The progress might surprise you. Only 0.81 seconds! @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2836 · 07.08.2024 г., 12:30

Italian Olympic gold medalist Thomas Ceccon was spotted sleeping in a park after complaining about the poor conditions at the Olympic Village in Paris. Despite the lack of air conditioning and noisy environment, Ceccon didn’t let it stop him from winning gold in the 100m backstroke. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2815 · 03.08.2024 г., 10:30

Another video from Olympics going viral. The cameraman closely following the athletes jumping on the trampoline throughout the entire event. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2804 · 31.07.2024 г., 17:46

The Egyptian fencer Nada Hafez revealed that she competed in the Olympics' women’s sabre competition — advancing to the round of 16 — while seven months pregnant. @Viral_Today / #Olympics

Hashtags

Viral Today

@viral_today · Post #2800 · 30.07.2024 г., 18:10

Bob the Cap Catcher: The First Viral Hero of the Paris Olympics 'Bob the Cap Catcher' became the first viral hero of the Paris Olympics when he jumped into the pool to save a swimmer's lost cap, earning loud cheers from the audience. @Viral_Today / #Olympics

Hashtags

Reza Pahlavi | رضا پهلوی

@officialrezapahlavi · Post #1387 · 08.08.2024 г., 16:40

جمهوری اسلامی قهرمانان ورزش ایران را وادار می‌کند تا وطن‌شان را ترک و بر خلاف میل‌شان زیر پرچم کشورهای دیگر در رقابت‌های بین‌المللی و المپیک شرکت کنند. این رژیم، حتی از رقابت دو ورزشکار ایرانی، دو دوست، که مثل هر رقابت ورزشی دیگری با برد و باخت همراه است، سوءاستفاده سیاسی می‌کند و تلاش می‌کند ایرانی را در مقابل ایرانی قرار دهد. من هم برای ناهید کیانی در رقابت فینال آرزوی پیروزی و کسب مدال طلا را دارم، و هم امیدوارم کیمیا علیزاده در ادامه بتواند مدال باارزش برنزش در المپیک ریو را تکرار کند. اما فارغ از هر نتیجه‌ای، ناهید و کیمیا هر دو برنده این صحنه هستند؛ و بازنده، رژیم پلید و اهریمنی جمهوری اسلامی است. باور دارم روزی دوباره، ورزشکاران ایرانی با افتخار و آزادانه زیر پرچم ملی ایران در مسابقات المپیک شرکت خواهند کرد، و با پشتیبانی یک ملت، برای ایران، افتخار به ارمغان خواهند آورد. The Islamic Republic forces Iran's champions to leave their homeland against their will and compete under the flags of other nations in international competitions like the #Olympics. This regime even attempts political exploitation of the competition between two Iranian athletes, two friends, where, like any other sporting contest, there are winners and losers. Yet the regime nonetheless tries to pit Iranian against Iranian. I wish Nahid Kiyani victory and a gold medal in the final and I also hope Kimiya Alizadeh can replicate her valuable bronze medal from the Rio Olympics. But regardless of the outcome, both Nahid and Kimiya are winners. The loser is the vile and evil Islamic Republic. I know that one day, Iranian athletes will again proudly and freely compete under the national flag of Iran in the Olympics and, with the support of a nation, bring Iran honor. @OfficialRezaPahlavi

Hashtags

FC Bayern English

@FCBayernEN · Post #224353 · 07.02.2026 г., 00:47

FC Bayern (TikTok) ❄️ 𝟮𝟬𝟮𝟲 𝗪𝗶𝗻𝘁𝗲𝗿 𝗢𝗹𝘆𝗺𝗽𝗶𝗰𝘀 🥇🥈🥉 The Allianz Arena shines in the colors of the German and Italian flags at the start of the Olympic Games in Milano Cortina. 🇩🇪🏟️🇮🇹 This is a symbol of solidarity and stands for the unique power of sport to bring people from all nations together. We keep our fingers crossed for all athletes and wish them a peaceful and successful Olympic and Paralympic Games.#Olympics#MilanoCortina2026

ПретходнаСтраница 1 од 3Следна