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

Резултати

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

Пребарај: #arter97

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

@NothingPhone2Updates · Post #285 · 19.04.2024 г., 12:10

arter97 Kernel | Android 14 | Nothing Phone (2) ✍️ Details: - Version: r17 - Codename: #Pong - Released: 19/04/24 🔽 Download: Normal & KSU Version 🆘 Support Threads: TG | XDA 🔖Tags : #Stock#Kernel#arter97#U ✨Changelogs: - Vibration strength customization added - Micro-optimized vibration motor device driver to be more efficient - Switched to LLVM 18.1.4 compiler - Reverted a new f2fs patch from r16 that slowed down boot 😎 Maintainer : @arter97 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #282 · 16.04.2024 г., 10:30

arter97 Kernel | Android 14 | Nothing Phone (2) ✍️ Details: - Version: r16 - Codename: #Pong - Released: 16/04/24 🔽 Download: Normal & KSU Version 🆘 Support Threads: TG | XDA 🔖Tags : #Stock#Kernel#arter97#U ✨Changelogs: - MGLRU enabled with relevant upstream improvements backported (better overall performance with less app kills) - BBRv3 backported - Switched to LLVM 18.1.3 compiler - Wi-Fi drivers updated to 2.0.9.21W - LA.VENDOR.1.0.r1-25100-WAIPIO.QSSI14.0 merged - NothingOS 2.5.3 changes merged - f2fs merged from Linux v6.9-rc1 😎 Maintainer : @arter97 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #269 · 15.03.2024 г., 07:55

arter97 Kernel | Android 14 | Nothing Phone (2) ✍️ Details: - Version: r15 - Codename: #Pong - Released: 15/03/24 🔽 Download: Normal & KSU Version 🆘 Support Threads: TG | XDA 🔖Tags : #Stock#Kernel#arter97#U ✨Changelogs: - Backported lazy RCU to improve power consumption - Other minor bug fixes and changes from Google ✍️ Note: - This kernel is only compatible with Stock A14 NOS rom. - Report issues (if any) in the support group with appropriate logs. 😎 Maintainer : @arter97 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #261 · 02.03.2024 г., 19:29

arter97 Kernel | Android 14 | Nothing Phone (2) ✍️ Details: - Version: r14 - Codename: #Pong - Released: 10/03/24 🔽 Download: Normal & KSU Version 🆘 Support Threads: TG | XDA 🔖Tags : #Stock#Kernel#arter97#U ✨Changelogs: r13: - OrangeFox recovery compatibility fixed - KernelSU v0.8.1 merged - LA.VENDOR.1.0.r2-09300-WAIPIO.QSSI13.0 merged - Wi-Fi drivers updated to 2.0.9.21S - Other minor bug fixes and changes from Google r14 - Switched to LLVM 18.1.0 compiler - Wi-Fi drivers updated to 2.0.9.21U ✍️ Note: - This kernel is only compatible with Stock A14 NOS rom. - Report issues (if any) in the support group with appropriate logs. 😎 Maintainer : @arter97 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #464 · 28.10.2024 г., 18:21

NothingMuchROM | Android 14 | Nothing Phone (2) Nothing OS with some handful modifications for a better experience ✍️ Details: - Version: r18 - Codename: #Pong - Released: 28/10/24 🔽 Download : Here 🆘 Support group: Here ⚙️ Installation: Here 💵 Donate: Buy this app 🔖Tags : #Stock#ROM#arter97#U#NothingPhone2 ✨Changelogs: - Stable release based on NOS 2.6 (Pong_U2.6-241016-1700) 😎 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #421 · 04.09.2024 г., 14:36

NothingMuchROM | Android 14 | Nothing Phone (2) Nothing OS with some handful modifications for a better experience ✍️ Details: - Version: r16 -> r17 - Codename: #Pong - Released: 15/10/24 🔽 Download : Here 🆘 Support group: Here ⚙️ Installation: Here 💵 Donate: Buy this app 🔖Tags : #Stock#ROM#arter97#U#NothingPhone2 ✨Changelogs: r16: Stable release based on NOS 2.6 [Pong_U2.6-240828-1751_2.6] r17 Custom bionic updated: Updated jemalloc to 6cc4217 (Sept 2024) Updated arm-optimized-routine to 3389879 (Oct 2024) 😎 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #344 · 08.07.2024 г., 14:53

NothingMuchROM | Android 14 | Nothing Phone (2) Nothing OS with some handful modifications for a better experience ✍️ Details: - Version: r15 (NOS 2.6.0) - Codename: #Pong - Released: 08/07/24 🔽 Download : Here 🆘 Support group: TG | XDA ⚙️ Installation: Here 🔖Tags : #Stock#ROM#arter97#U#NothingPhone2 ✨Changelogs: - Stable release based on 2.6.0 - Custom bionic updated to use the latest AOSP compiler and fix several minor issues in the math library. 😎 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #337 · 02.07.2024 г., 11:41

NothingMuchROM | Android 14 | Nothing Phone (2) Nothing OS with some handful modifications for a better experience ✍️ Details: - Version: r14 (NOS 2.5.6) - Codename: #Pong - Released: 02/07/24 🔽 Download : Here 🆘 Support group: TG | XDA ⚙️ Installation: Here 🔖Tags : #Stock#ROM#arter97#U#NothingPhone2 ✨Changelogs: - Stable release based on NOS 2.5.6 - Dirac is back, thanks to the fix from gotenksIN ✍️ Note: - If you don't want dirac, stick to the r13 build based on NOS 2.5.6 😎 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #721 · 11.03.2026 г., 07:28

NothingMuchROM | Android 16 | Nothing Phone (2) ✍️ Details: - Version: r40 - Codename: #Pong - Released: 10/03/26 🔽 Download : Here 🆘 Support group: Here ⚙️ Installation: Here 🌳 Source: Here 🔖Tags : #Stock#ROM#arter97#V#NothingPhone2 ✨ Changelogs - Update base to 4.0 (Pong_B4.0-260226-0955) 🗒 Note: - Back up your data before proceeding. - Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario. - Recovery flashable firmwares can be found here. - It is recommended to use arter97's latest kernel build with this ROM. 👤 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #670 · 04.09.2025 г., 08:27

NothingMuchROM | Android 15 | Nothing Phone (2) ✍️ Details: - Version: r39 - Codename: #Pong - Released: 20/09/25 🔽 Download : Here 🆘 Support group: Here ⚙️ Installation: Here 🔖Tags : #Stock#ROM#arter97#V#NothingPhone2 ✨ Changelogs - Update base to Pong-V3.2-250917-1451 🗒 Note: - Back up your data before proceeding. - Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario. - Recovery flashable firmwares can be found here. - It is recommended to use arter97's latest kernel build with this ROM. 👤 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #650 · 15.07.2025 г., 04:42

NothingMuchROM | Android 15 | Nothing Phone (2) ✍️ Details: - Version: r37 - Codename: #Pong - Released:15/07/25 🔽 Download : Here 🆘 Support group: Here ⚙️ Installation: Here ✨ Changelogs: Here 🔖Tags : #Stock#ROM#arter97#V#NothingPhone2 🗒 Note: - Back up your data before proceeding. - Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario. - Recovery flashable firmwares can be found here. - Stable release based on 3.2 (Pong_V3.2-250708-2227_3.2) - It is recommended to use arter97's latest kernel with this ROM. 👤 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #617 · 15.05.2025 г., 04:56

NothingMuchROM | Android 15 | Nothing Phone (2) ✍️ Details: - Version: r36 - Codename: #Pong - Released: 23/05/25 🔽 Download : Here 🆘 Support group: Here ⚙️ Installation: Here ✨ Changelogs: Here 🔖Tags : #Stock#ROM#arter97#V#NothingPhone2 🗒 Note: - Back up your data before proceeding. - Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario. - Recovery flahsable firmwares can be found here. - Flashing super is enough for users coming from r35. - Stable release based on NOS 3.0, Build: Pong-V3.0-250506-1805. - It is recommended to use arter97's latest kernel with this ROM. 👤 Developer: @arter97 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

ПретходнаСтраница 1 од 4Следна