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

Резултати

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

Пребарај: #cop26

当前筛选 #cop26清除筛选
Reuters: World

@reutersworldchannel · Post #149241 · 12.10.2021 г., 01:24

Explained: Carbon pricing and COP26 This year’s COP26 climate meeting aims to secure far bolder action from the nearly 200 countries that signed the 2015 Paris Agreement. Global carbon pricing is one of the mechanisms they hope will achieve that #News#Reuters#COP26 Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149553 · 19.10.2021 г., 09:47

Designer Vivienne Westwood shares her 'Letter to Earth' British fashion designer Vivienne Westwood and Nigerian author Ben Okri read out their 'Letters to the Earth' as part of a campaign urging action against climate change in the run-up to the U.N. #COP26 summit. #News#Reuters#ClimateChange Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149550 · 19.10.2021 г., 02:04

Explained: Key things to watch for at COP26 As public pressure grows for action to limit climate change, world leaders from nearly 200 countries will convene in Glasgow, Scotland, at the end of October for the COP26 conference. Here are the key climate issues that need resolution. #COP26#News#Reuters#ClimateChange Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149403 · 15.10.2021 г., 13:02

Xi will not attend COP26 in person, report says Chinese President Xi Jinping will not attend the COP26 climate summit in person, British Prime Minister Boris Johnson has been told, The Times newspaper reported. #News#Reuters#XiJinping#COP26 Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149220 · 11.10.2021 г., 15:47

LIVE: The WHO launches its COP26 report The World Health Organization launches its COP26 report "The Health Argument for Climate Action" along with an open letter from 45 million health professionals worldwide calling for an ambitious outcome at the upcoming event in Glasgow. #COP26#COP26Glasgow#environment#Reuters#Live#News Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149263 · 12.10.2021 г., 18:16

COP26 president Alok Sharm says leaders 'must step up' The G20 group of leading economies must come forward with more ambitious 2030 climate action plans before the United Nations COP26 conference, its president, Alok Sharma said. #COP26#ClimateChange#environment#AlokSharma#News#Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149316 · 13.10.2021 г., 17:27

LIVE: IMF's Georgieva, COP26's Sharma talk about climate change ahead of COP26 IMF Managing Director Kristalina Georgieva and COP26 President and British Minister Alok Sharma discuss climate change in the run up to the U.N. Climate Change Conference during the World Bank/IMF annual meetings. #Reuters#News#Live#IMF#COP26#environment#climate ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149258 · 12.10.2021 г., 16:27

Thunberg expects 'meaningless' pledges at COP26 For activist Greta Thunberg, success at the upcoming U.N. climate conference would be possible if world leaders honestly admit that their action is not living up to their words. #GretaThunberg#COP26#UNClimateConference#ClimateChange#News#Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149236 · 11.10.2021 г., 22:21

Prince Charles talks climate change Ahead of the U.N. Climate Change Conference COP26, Prince Charles shares Greta Thunberg's concerns that world leaders 'just talk' about climate change and are not doing enough to prevent its catastrophic impact. #News#Reuters#PrinceCharles#ClimateChange#Environment#GlobalWarming#COP26 Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖