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

Резултати

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

Пребарај: #crdroid

当前筛选 #crdroid清除筛选
Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #153 · 12.09.2024 г., 17:15

#crDroid#diting New Version 10/09/2024: Gapped version Download Changelog: Updated to version 10.8 Note: Firmware is NOT included. Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt By@Mohammadnt96

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #120 · 12.07.2024 г., 14:25

#crDroid#diting New Version 11/07/2024: Gapped version Download Changelog: crDroid v10.6 Updated to June security patch Including MiuiCamera Note: Firmware is NOT included. This is beta version. Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt By@Mohammadnt96 Follow@xiaomi_12tpro_updates Join@xiaomi_12tpro_chat

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #84 · 26.02.2024 г., 21:12

#crDroid#diting New Version 25/02/2024: Gapped version Download Changelog: crDroid v10.2 SMS fixed Kernel Switched to HyperOS Used HyperOS blobs Notes: Use latest skkk twrp (v8.6) Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt Discussion: Xiaomi 12T Pro crDroid

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #63 · 02.02.2024 г., 03:40

#crDroid#diting New Version 02/02/2024: Gapped version Download Changelog: crDroid v10.1 fod fixed for both touchscreens miui camera included Known Issues: Opening photo in miui camera Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt Discussion: Xiaomi 12T Pro crDroid

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #17 · 11.11.2023 г., 00:57

#crDroid#Unofficial#diting#A14 Crdroid 10.0 UNOFFICIAL | Android 14 Updated: 11-11-2023 ▪️Download ▪️Support Changelog: • Initial A14 build with oss vendor Notes: Known Issues: Auto brightness must be disabled. otherwise screen will not wake after lock Fod on k50u does not work Credits: Thanks to @TeamMEX_XDA for providing dt By@Mohammadnt96 Follow@xiaomi_12tpro_updates Join@xiaomi_12tpro_chat

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #14 · 10.11.2023 г., 01:58

#crDroid#Unofficial#diting#A13 Crdroid 9.10 UNOFFICIAL | Android 13 Updated: 05-11-2023 ▪️Download ▪️Support Changelog: • Initial Vendor OSS Build Credits: Thanks to @TeamMEX_XDA for providing dt By@Mohammadnt96 Follow@xiaomi_12tpro_updates Join@xiaomi_12tpro_chat

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #374 · 30.07.2024 г., 11:52

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.6 - Status: #Official - Device: #Pong - Released: 30/07/24 ⬇️ Download: ROM (Vanilla) | Gapps Package 📔 Instructions: Here 🎄 Device tree : Here 📝 Changelogs : Here 🆘 Support: TG | XDA 🏷 Tags: #AOSP#ROM#CrDroid#U ✍️ Note: - Base firmware 2.6.0 is recommended - Dirty flash possible from previous july build - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu Dyavanapelli for DT Base - Hellboy for Meteoric kernel and Glyph changes - Fabian for PA Glyph Implementation 👤 Maintainer: @Ghosutox 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #353 · 15.07.2024 г., 19:46

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.6 - Status: #Official - Device: #Pong - Released: 15/07/24 ⬇️ Download: ROM (Vanilla) | Gapps 📔 Instructions: Here 🎄 Device tree : Here 🆘 Support: TG | XDA 🏷 Tags: #AOSP#ROM#CrDroid#U ✨Changelogs: - Initial QPR3 release ✍️ Note: - Base firmware 2.6.0 is recommended - Clean flash must - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu Dyavanapelli for DT Base - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testing Team 👤 Maintainer: @Ghosutox 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #296 · 15.05.2024 г., 14:18

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.5 - Status: #Official - Device: #Pong - Released: 15/05/24 ⬇️ Download: ROM (Vanilla) | ROM Fastboot | Gapps 📔 Instructions: Here 🆘 Support: TG | XDA 💰 Donate: PayPal | BuyMeACoffee 🏷 Tags: #AOSP#ROM#CrDroid#U ✨Changelogs: - Update to CrDroid 10.5 - Added ParanoidGlyph - Fixed SMS and SIM issue ✍️ Note: - Base firmware 2.5.5 is recommended - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu Dyavanapelli for DT bring up and fix SMS issue - Hellboy017 for kernel - Pong TG Dev & Testing Team 👤 Dev: @DylanAkp 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #242 · 08.02.2024 г., 22:58

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.2 - Status: #Official - Device: #Pong - Released: 08/02/24 ⬇️ Download: ROM (Vanilla) | Gapps 📔 Instructions: Here 💬 Support Group: Here 🏛 XDA: Here 💰 Donate: PayPal | BuyMeACoffee 🏷 Tags: #AOSP#ROM#CrDroid#U ✨Changelogs: - Initial official build - Firmware removed - Rebased on NOS 2.5.2 - Added Reverse Wireless Charging - Switched to qcom telephony - Added Glyphify (An alternative app to ParanoidGlyph I made, more to come in future updates) ⛔️ Known Issues: - Issue with reception of SMS Enabling and disabling SIM card from settings fix the issue until the next boot ✍️ Note: - Base firmware 2.5.2 is recommended - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu_Dyavanapelli for DT bring up - Hellboy017 for kernel - Przekichane for DT & vendor fixes on A13 » A14 - Pong TG Dev & Testing Team 👤 Dev: @DylanAkp 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #226 · 05.01.2024 г., 13:53

CrDroid - Unofficial | Android 14 | Nothing Phone (2) 📝 Details: - Version : v10.x - Status: #Unofficial - Device : #Pong - Released : 04/01/24 ⬇️ Download : ROM (Vanilla) | Gapps 📔 Instructions: Here 📸 Screenshots : Here 💬 Support Group : Here 🏛 XDA : Here 💰 Donate : PayPal | BuyMeACoffee 🏷Tags : #AOSP#ROM#CrDroid#U ✨Changelogs: - Rebased on NothingOS 2.5.1 - Fixed stutters - Fixed Face Unlock - More CrDroid settings implemented - Updated to Android QPR1 (Security patch December 2023) ✍️ Note: - Base firmware 2.5.1 is recommended - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu_Dyavanapelli for DT Bringup - Hellboy017 for kernel - Przekichane for DT and Vendor fixes on A13 » A14 - Pong TG Dev and Testing Team for all help 👤 Dev : @DylanAkp 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #216 · 18.12.2023 г., 14:30

CrDroid - Unofficial | Android 14 | Nothing Phone (2) 📝 Details: - Version : v10.x - Status: #Unofficial - Device : #Pong - Released : 18/12/23 ⬇️ Download : Rom (Vanilla) | Gapps 📔 Instructions: Here 📸 Screenshots : Here 🏛 XDA : Here 💰 Donate : PayPal 🏷Tags : #AOSP#ROM#CrDroid#U ✨Changelogs: - Intitial A14 build based ✍️ Note: - Please be on NOS 2.0.4 before flashing. (Not yet tested from 2.5.1) - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu_Dyavanapelli for DT Bringup - Hellboy017 for kernel - Przekichane for DT and Vendor fixes on A13 » A14 - Snuvig for early tests - Pong TG Dev and Testing Team for all help 👤 Dev : @DylanAkp 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2

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