@NEASingapore · Post #1184 · 07.12.2025 г., 01:04
Batteries thrown in blue recycling bins can lead to 🔥 fires 🔥. Recycle batteries in e-waste bins instead: go.gov.sg/e-waste #RecycleRight#3Rs
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #22 · 19 јан.
Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic
Hashtags
Пребарај: #3rs
@NEASingapore · Post #1184 · 07.12.2025 г., 01:04
Batteries thrown in blue recycling bins can lead to 🔥 fires 🔥. Recycle batteries in e-waste bins instead: go.gov.sg/e-waste #RecycleRight#3Rs
Hashtags
@NEASingapore · Post #373 · 26.06.2022 г., 01:27
Ever wondered what your used notebooks, tissue boxes and loose paper becomes after putting them into the blue bins? They are treated and recycled into new items such as egg trays! #3Rs#RecycleRight Not sure what can be recycled? Find out at go.gov.sg/recycleright!
Hashtags
@NEASingapore · Post #368 · 12.06.2022 г., 01:30
Recycling plastic can be confusing with the many plastic identification numbers. To keep things simple, just recognise and remember that these 3 groups that are ok to be put into Bloobin! Not sure what can be recycled? Find out at go.gov.sg/recycleright! #3Rs#RecycleRight
Hashtags
@NEASingapore · Post #335 · 14.04.2022 г., 09:31
Here’s another test for your recycling knowledge! Do you know which items can or cannot be placed into the blue recycling bins? Not sure what can be recycled? Find out at go.gov.sg/recycleright! #3Rs#RecycleRight
Hashtags
@NEASingapore · Post #291 · 12.12.2021 г., 03:29
It’s finally that time of year to pull out our festive decorations! Rather than buy new decorations each year, keep them to be reused each year -- they never go out of style 😊#SayYEStoWasteLess#3Rs
Hashtags
@NEASingapore · Post #280 · 04.11.2021 г., 02:00
#RecycleRight Tip: Flatten cardboard boxes, even smaller ones such as tissues boxes. This gives you more room in your recycling corner, and frees up space in the recycling bin! #3Rs
Hashtags
@NEASingapore · Post #338 · 21.04.2022 г., 09:31
#DidYouKnow not all takeout containers or disposable plastics can be recycled? If they’re greasy or dirty, bin them to avoid contaminating other recyclables. Not sure what can be recycled? Find out at go.gov.sg/recycleright! #3Rs#RecycleRight
Hashtags
@NEASingapore · Post #450 · 25.10.2022 г., 00:45
Dressing up as your favourite superhero this Halloween? Get creative and make a costume using everyday household items. When you’re done, recycle or reuse what you can of your outfit, so that your superhero legacy will continue to live on 🦸♂️ #3Rs#ReduceReuseRecycle
Hashtags
@NEASingapore · Post #407 · 19.08.2022 г., 08:01
Be a green champion by refusing disposable plastic bags and using a reusable bag. Marvel at the environmental gains you achieve on a daily basis 💪#3Rs#ReduceReuseRecycle
Hashtags
@NEASingapore · Post #1219 · 02.01.2026 г., 01:03
This season is giving that check-clean-recycle mantra! ✅ Check if it’s recyclable 🧼 Clean it (no food or liquid waste) ♻️ Recycle Every small step makes a big difference! #3Rs#RecycleRight#TowardsZeroWaste#SustainableSG
@NEASingapore · Post #1215 · 31.12.2025 г., 00:54
Glow-up your home with a recycling corner! Keep a bin, box or bag right beside your trash bin to make recycling effortless. ✅ Drop in only clean recyclables 🚫 Keep food scraps & oily packaging out Soon, recycling will feel like second nature! #3Rs#RecycleRight#TowardsZeroWaste#SustainableSG
@NEASingapore · Post #1198 · 20.12.2025 г., 00:54
This season is giving recycle-every-recyclable challenge! All clean recyclables = ✅ win One dirty container = 🚫 big ick #3Rs#RecycleRight#TowardsZeroWaste#SustainableSG