TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

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

Резултати

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

Пребарај: #lunaris

当前筛选 #lunaris清除筛选
Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #694 · 23.11.2025 г., 14:26

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.5 - Codename: #Pong - Updated : 23/11/'25 🔽 Download: Here | Mirror 🆘 Support : Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC | Paypal 🔖 Tags : #ROM#AOSP#lunaris ✍️ Note: • Latest base firmware is recommended • Strong integrity by default • Ksu inbuild • If you face any bugs, report with logs. • Initial NTcamera and dolby support available 🏆 Credits: - Hellboy for kernel - Fabian and Hellboy for Glyph Implementation 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #683 · 14.10.2025 г., 16:23

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.4 - Codename: #Pong - Updated : 14/10/'25 🔽 Download: Here | Mirror 🆘 Support : Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC | Paypal 🔖 Tags : #ROM#AOSP#lunaris 📚 Device: - Custom Call glyph pattern implementation - Add shake to toggle glyph torch - Tune powerhint - Enable WiFi 6 - Add configurable ringer mode for flip to glyph ✍️ Note: • Latest base firmware is recommended. • Strong integrity by default • If you face any bugs, report with logs. • Initial NTcamera and dolby support available 🏆 Credits: - Hellboy for kernel - Fabian and Hellboy for Glyph Implementation 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #672 · 15.09.2025 г., 14:41

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.2 - Codename: #Pong - Updated : 15/09/'25 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC 🔖 Tags : #ROM#AOSP#lunaris ✍️ Note: • Latest base firmware is recommended. • If you face any bugs, report with logs. • Initial NTcamera and dolby support available 🏆 Credits: - Hellboy for kernel - Fabian and Hellboy for Glyph Implementation 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #661 · 16.08.2025 г., 12:42

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.2 - Codename: #Pong - Updated : 16/08/'25 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC 🔖 Tags : #ROM#AOSP#lunaris ✍️ Note: • Latest base firmware is recommended. • If you face any bugs, report with logs. • NTcamera and dolby support available 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #655 · 27.07.2025 г., 16:03

LunarisAOSP | A16 | Nothing Phone 2 (Pong) Updated : 27/07/'25 ✍️ Details: - Version: Official - Codename: #Pong 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📖 Changelogs: Here 📸 Screenshots:Here 🔖 Tags : #ROM#AOSP#lunaris 📚 Changelogs - 15-08 - Add Simulated Nothing Charging service - FlipToGlyph: Vibrate instad of silent - Enable AIDL fastboot HAL - Sync props from stock ✍️ Note: - Kernel is prepatched KSU - Dirty/ota flash possible from previous build - Latest base firmware recommended - Update inbuilt pif and import keybox xml for integrity 😎 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #647 · 03.07.2025 г., 04:48

LunarisAOSP | A16 | Nothing Phone 2 (Pong) Updated : 03/07/'25 ✍️ Details: - Version: Official - Codename: #Pong 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📸Screenshots:Here 🔖 Tags : #ROM#AOSP#lunaris 📑Changelogs - 16/07/25 - Use expressive design for Singularuty icons - Add QuickTap service - Tune QS round tile - Fix cloned profile issues - Fix Keyguard slice - Screenrecord: Add delete action to the notification - Update PIF - Fix bluetooth time out ✍️ Note: 16/07/25 - Kernel is prepatched KSU - Dirty/ota flash possible from previous build - Base firmware 3.0 is recommended - Update inbuilt pif and import keybox xml for integrity 😎 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #453 · 17.10.2025 г., 21:33

#Lunaris#AOSP#UNOFFICIAL#A16#BKA#Diting Lunaris-AOSP UNOFFICIAL V3.4 | A16 Released: 17/10/2025 Download : SF | Mirror Screenshots : Here Changelog : Here Support:Group Changelogs: • Initial build • Hyper Camera by default • Dolby Audio by default • Support KernelSU Notes: If you want to receive regular updates, you can donate and we will add you to VIP support. Credits:Here By@Jezzay97 | Donate Follow@xiaomi_12tpro_updates Join@xiaomi12tpro_chat