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

Резултати

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

Пребарај: #durban

当前筛选 #durban清除筛选

🐬 uShaka Marine World — a themed park opened in 2004 in Durban, KwaZulu-Natal Province. 🏄‍♂️ It is one of the largest entertainment complexes in South Africa, known for its exciting mix of marine adventures and active recreation. 🐠 🎥 Video: https://t.me/rusbig5/7760 #SouthAfrica#Durban#uShakaMarineWorld#TravelSouthAfrica#ExploreAfrica#AdventureTime

🇿🇦 ЮАР готовится к Рождеству 🎄 Вот так выглядит Дурбан — третий по величине город страны: праздничные огни, океанский бриз и летнее настроение ✨🌴 #Рождество#НовыйГод#ЮАР#Дурбан _______________ 🇿🇦South Africa is getting ready for Christmas 🎄 This is what Durban, the country’s third-largest city, looks like — festive lights, ocean vibes, and a true summer Christmas ✨🌴 #Christmas#NewYear#SouthAfrica#Durban

🏇 Dick Francis (1920–2010) was a British steeplechase jockey (over 350 wins) and the author of 43 crime novels. 📖 The book Smokescreen (1972) and its film adaptation is a detective story set in South Africa. 🎬 Plot: a popular British actor flies to South Africa to find out why an elderly lady’s horses are performing so poorly. But he soon discovers that an ill-wisher is out to get him. 🏇 The novel features detailed accounts of horse races in Durban and thrilling scenes in Kruger National Park, immersing readers in the atmosphere of African adventure. #DickFrancis#Literature#Books#CrimeFiction#SouthAfrica#Kruger#Durban

🍛Two Iconic South African Curries 🇿🇦 Two of the most famous curries in South African cuisine represent the two port cities — Cape Town on the west coast and Durban on the east. ⚓️ Even their names reflect their origins: 🌶Cape Malay Curry Powder refers to Cape Town’s Malay community, 🔥Durban Curry Masala — to Durban’s Indian community. The Cape curry is slightly sweeter and milder, while the Durban curry is hotter and more vibrant thanks to the addition of Kashmiri red chili. 🌶 Source: https://t.me/africamother/800 #SouthAfrica#Food#Cuisine#Cooking#CapeTown#Durban#Spices#Curry

The only revolving restaurant in the Southern Hemisphere is in Durban!🇿🇦 The Roma Revolving Restaurant, opened in 1973, is famous not only for its 360° panoramic views of the city but also for its excellent Italian cuisine. 🇮🇹 🍽 It’s located on the 32nd floor of the iconic John Ross House — and we’ll tell you more about this landmark in an upcoming post! 🎥Video (01:53) #Durban#SouthAfrica#RomaRevolving#Restaurants#Architecture#ItalianFood#TravelSouthAfrica#CityViews

🚩Сегодня, 8 июня 2025, ультрамарафон Comrades стартовал в ЮАР в 08:30 по Екатеринбургу (в 06:30 по Москве) и продлится 12 часов. На фото — команда марафонцев из Екатеринбурга, которую поддерживает Уральский горнопромышленный холдинг. Чтобы прочувствовать атмосферу, посмотрите видео! _______________ 🚩 Today’s the day! On June 8, 2025, the Comrades ultramarathon began in South Africa at 8:30 AM Yekaterinburg time (that’s 6:30 Moscow time), and runners have up to 12 hours to finish. Featured is the Yekaterinburg team, supported by the Ural Mining Holding (UMH). Click to watch videos to get the feel of the event! #sport#marathon#Comrades#Durban#Pietermaritzburg#ЮАР#спорт#марафон#Комрадс

🏙The John Ross House in Durban is a 33-storey skyscraper on the iconic Victoria Embankment. Named after John Ross (real name: Charles Rawden Maclean), who at just 15 years old walked 600 km (370 mi) from Port Natal to Delagoa Bay and back — to bring medicine and supplies to the crew of a shipwrecked vessel. It happened in1825. ⛵️ 🗿 A statue of him stands outside the building. 🍽 At the top of the tower is the Roma Revolving Restaurant, offering panoramic views of Durban. 🏢 The building stands 109 meters (358 ft) tall and was renovated in 2009. Today, it serves both residential and commercial purposes. #Durban#SouthAfrica#Architecture#History#JohnRoss#Landmarks#VictoriaEmbankment#Skyscrapers#RomaRestaurant#Africa

🌴Victoria Embankment in Durban is one of the city’s most iconic waterfront areas — both a major transport route and a symbol of urban identity. 🌆 📍 Along the Embankment you’ll find: 🔹 the famous John Ross House with the Roma Revolving Restaurant 🔹 Durban’s city hall and court buildings 🔹 the historic yacht basin 🔹 monuments, greenery, and sweeping views of the bay 🚶‍♀️ It’s a perfect place for walks, photos, and taking in the rhythm of Durban’s harbor life — where colonial history meets modern African energy. 📹 Video #Durban#VictoriaEmbankment#SouthAfrica#Cityscape#Waterfront#History#UrbanAfrica#TravelSouthAfrica#Architecture#JohnRossHouse#ExploreDurban