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

Резултати

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

Пребарај: #neaofficers

当前筛选 #neaofficers清除筛选
NEA Singapore

@NEASingapore · Post #610 · 05.08.2023 г., 02:00

Rats are nocturnal and shy creatures that prefer to stay in small and dark spaces, making it challenging to track them down. Apart from conducting rat surveillance at publicly accessible places islandwide, #NEAofficers also carry out risk-based checks at various known hotspots. Check out the different types of equipment used to overcome challenges faced during inspections, and learn more here: https://fb.watch/laCn_dEdrY/

Hashtags

NEA Singapore

@NEASingapore · Post #548 · 12.05.2023 г., 11:12

3 local cases of Zika virus infection have been confirmed in the Kovan area in the past month. Vector control operations have commenced in the vicinity. As our #NEAofficers are conducting inspections and indoor spraying of insecticides, we urge residents to cooperate with them. Besides eliminating mosquito breeding habitats, those residing at Zika and dengue cluster areas should carry out ‘S-A-W’ actions: - Spray insecticide in dark corners around the house - Apply insect repellent regularly - Wear long-sleeve tops & long pants go.gov.sg/nea-zika-12may2023

Hashtags

NEA Singapore

@NEASingapore · Post #543 · 01.05.2023 г., 01:30

Happy Labour Day! Here’s a huge THANK YOU to all who are working hard to keep our nation running. A special shout-out too to thank our cleaners for keeping our city clean and green, our hawkers for working tirelessly to provide delicious hawker fare, as well as #NEAofficers for ensuring a clean and sustainable environment.

Hashtags

NEA Singapore

@NEASingapore · Post #80 · 21.07.2020 г., 04:53

#NEAOfficers like Sulaiman work with these waste collectors to ensure biohazardous waste will be collected and incinerated quickly, in a way that is safe for waste handlers and the environment during the COVID-19 period. Find out what he does on our Instagram story highlight at www.instagram.com/nea_sg!

Hashtags

NEA Singapore

@NEASingapore · Post #34 · 07.04.2020 г., 09:49

#NEAOfficers prepared a surprise for our hawkers last week! 14,000 care packages will be distributed to our hawkers who have been working tirelessly so that we can continue to enjoy our favourite hawker food. https://youtu.be/T_ArJhAOAHA

Hashtags

NEA Singapore

@NEASingapore · Post #474 · 13.12.2022 г., 00:45

Beware litterbugs - your poorly discarded items could become the stink of the neighbourhood! Let’s avoid attracting unwanted smells and pests, by properly binning our rubbish. Together, we can #KeepSGClean! Our #NEAofficers have been working hard to apprehend high-rise littering offenders, using data analytics to prioritise camera deployment. As high-rise littering cases are usually harder to detect, they may take some time to be resolved. If you witness such incidents, do take note of specific details such as date, time and precise location (block stack or column), and include them when submitting feedback (www.nea.gov.sg/feedback), to help with our investigation.

NEA Singapore

@NEASingapore · Post #603 · 25.07.2023 г., 01:00

#DidYouKnow that there are 3 main rat species found in Singapore? From roof rat to sewer rat to house mouse, find out how our #NEAofficers carry out rat surveillance and look for signs of rat activity during their inspections, and get useful tips on rat prevention measures: https://fb.watch/laCn_dEdrY/

NEA Singapore

@NEASingapore · Post #199 · 01.06.2021 г., 04:13

#SGDengueUpdate Over 2,700 dengue cases have been reported in 2021. Increasing Aedes aegypti mosquito population, and higher circulation of less common Dengue virus serotypes 3 and 4 to which we have lower population immunity, contribute to higher risk of dengue transmission. While our #NEAOfficers continue to conduct targeted inspections at areas with higher mosquito population, and step up operations at dengue cluster areas, residents should do the #MozzieWipeout regularly to #BLOCKDengue. https://go.gov.sg/nea-dengue-1jun2021

NEA Singapore

@NEASingapore · Post #65 · 15.06.2020 г., 04:00

Where there are wet and dark crevices, NEA’s Dengue Inspection Officer Marthandan will be there. Let him show you how he and his team spot and tackle mosquito breeding in the areas around you! Join him in our #NEAOfficers Story Highlight on our Instagram profile (www.instagram.com/nea_sg)! #SGUnited#SGTogether

NEA Singapore

@NEASingapore · Post #346 · 09.05.2022 г., 04:17

Whenever NEA receives feedback on noise or smell nuisance, #NEAofficers such as Joey would investigate the root cause and try to resolve the issues for residents. Read on to find out more about his winning formula: https://www.facebook.com/NEASingapore/posts/324902236450865 #PeopleofNEA#NEA20