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

Резултати

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

Пребарај: #testing

当前筛选 #testing清除筛选
IT Masters

@ITmastersuz · Post #11664 · 28.09.2024 г., 04:56

S24 vs 15 Pro Max batareya sinovi 🔥 🔥 - Samsung S24 👍 - iPhone 15 Pro Max 👉Bizning barcha loyihalar | #testing

Hashtags

Momogram

@momogram_update · Post #1285 · 16.04.2026 г., 03:57

#testing v12.6.4 cb9a1daa95 r1128 Fixed: - Content in ChatEditTypeActivity not aligned Misc: - APK signature changed - nekox.messenger.broken is now momo.gram Note: In general, secret chats will be lost when you switch between apps starting from the last build. Momogram contains a secret chat backup/restore helper that can partially mitigate this problem. The contents of secret chats can be migrated to the new Momogram release (view-only; you still have to create a new secret chat for future messages). Note that this functionality isn’t guaranteed. Make sure you don’t uninstall the old build before confirming the content is properly restored on the other side. Steps to migrate: - Open Momo account settings with previous build - Tap on "Backup Secret Chats" - Enter a password - Share it to yourself (Saved Messages) - Install this build - Tap on the file you shared to yourself - Enter the password you specified earlier and press OK PS. While the exported backup is always encrypted, it's advised to delete the backup as soon as you done with the migration. PPS. To prevent issues, the backup file created is restricted to be used with the same upstream version, try to restore on a different version will be resulted in decrypt error

Hashtags

Momogram

@momogram_update · Post #1275 · 10.04.2026 г., 13:04

#testing v12.6.4 899700cb58 r1127 Fixed: - A typo in Momo settings - Duplicated share button in custom tab UI for certain browsers - (unverified) Random ANR & crash fix

Hashtags

Momogram

@momogram_update · Post #1264 · 07.04.2026 г., 13:08

#testing v12.6.4 6a8da4a514 r1126 Added: - Randomize attached file name (Note. names of files with existing cache won't be randomized) - Hide AI button in edit text field Fixed: - Details button not showing for some messages - Repeat scheduled message not hidden for non-premium users - New Telegram translate UI (TranslateAlert3)

Hashtags

Momogram

@momogram_update · Post #1254 · 06.04.2026 г., 15:17

#testing v12.6.3 013d69a41f r1125 First 12.6.3 test build Added: - Disable pull down to show search bar at chat list (thx Nagram) Misc: - Abandon outdated local Chinese translations (replaced with official beta language pack)

Hashtags

Momogram

@momogram_update · Post #1244 · 03.04.2026 г., 15:02

#testing v12.5.1 b043950be7 r1124 Added: - Active session checker to check if there's active session of potentially malicious clients (Please consider share API ID from experimental settings if you get the warning message) Fixed: - Passkey login for Bitwarden (Thx Nagram) - Edit/Promote admin in groups

Hashtags

Momogram

@momogram_update · Post #1193 · 23.02.2026 г., 09:47

#testing v12.4.1 6ecd8a6547 r1120 Added: - Hide bottom navigation tabs (Special Thanks: tehcneko) Fixed: - Send button size/position in chat list when forwarding Misc: - Close search settings by taping on bottom tab - Move appearance settings to a separate page - Show proxy in chat list menu

Hashtags

Momogram

@momogram_update · Post #1188 · 21.02.2026 г., 10:40

#testing v12.4.1 339a548ad2 r1119 Added: Switch account by long click on title Basically usable now, may still have some minor bugs, but most annoying glitches were fixed, thanks for everyone helped testing

Hashtags

123•••56
ПретходнаСтраница 1 од 6Следна