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

Резултати

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

Пребарај: #soccer

当前筛选 #soccer清除筛选
Main Event | Sport News

@maineventnews · Post #116 · 31.07.2024 г., 10:02

Two days ago, Triestina from Serie C sold defender Lorenzo Moretti. However, the club quickly found a replacement by signing his twin brother Andrea. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

Main Event | Sport News

@maineventnews · Post #115 · 31.07.2024 г., 08:02

Yamal is vacationing in Marbella a day after his girlfriend, Alex Padiya, was seen on another guy's lap during an Instagram live stream. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

Main Event | Sport News

@maineventnews · Post #111 · 30.07.2024 г., 16:01

Manchester United is discussing the construction of a new home stadium with a capacity of 100,000 spectators, costing £2 billion. The club considers the £1.2 billion renovation of Old Trafford to be less advantageous. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

Main Event | Sport News

@maineventnews · Post #110 · 30.07.2024 г., 14:01

Real Madrid is working on signing Trent Alexander-Arnold and Alphonso Davies on free transfers in 2025, according to Matteo Moretto. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

Main Event | Sport News

@maineventnews · Post #107 · 30.07.2024 г., 08:01

Taylor Swift drew over 70,000 fans at the Olympic Stadium in Munich, which hosted the finals of the 1974 World Cup and Euro 1988. Fans who couldn't get tickets listened to the concert from a nearby hill. German police counted 40,000 people there. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

Main Event | Sport News

@maineventnews · Post #106 · 30.07.2024 г., 06:01

Mbappe received a new BMW i7 M70 xDrive worth 186,750 euros from Real Madrid. Perez has the same model. The car has a power output of 660 hp, accelerates from 0 to 100 km/h in 3.7 seconds, features massage seats, and has a top speed of 250 km/h. However, Kylian doesn't have a driver's license. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

Main Event | Sport News

@maineventnews · Post #103 · 23.07.2024 г., 18:02

A warm welcome for Rakitić from Hajduk fans! Ivan specifically broke his contract with Al-Shabab to play for the Split-based club. The 36-year-old footballer will be playing in his native Croatia for the first time in his career. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

Main Event | Sport News

@maineventnews · Post #101 · 23.07.2024 г., 14:02

Raphaël Varane will sign a two-year contract with Como (Fabrizio Romano). The Serie A newcomer already has Reina, Belotti, and Alberto Moreno in their squad, and the club is also trying to sign Martial and Depay. #Soccer 👁Subscribe to Main Event | Sport News

Hashtags

123•••56
ПретходнаСтраница 1 од 6Следна