@chessio_EN · Post #104 · 16.01.2025 г., 08:48
Find the best move for Black #Chessio#DailyPuzzle
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
Пребарај: #dailypuzzle
@chessio_EN · Post #104 · 16.01.2025 г., 08:48
Find the best move for Black #Chessio#DailyPuzzle
Hashtags
@chessio_EN · Post #103 · 15.01.2025 г., 13:01
Find the best move for White #Chessio#DailyPuzzle
Hashtags
@WinPath · Post #7122 · 06.09.2025 г., 11:19
🎩Agent 301 Puzzle | Sept 6 🧩Cards in Order:11:10:7:13 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7109 · 04.09.2025 г., 14:21
🎩Agent 301 Puzzle | Sept 4 🧩Cards in Order:13:16:8:1 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7097 · 02.09.2025 г., 16:13
🎩Agent 301 Puzzle | Sept 2 🧩Cards in Order:5:9:13:1 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7089 · 01.09.2025 г., 19:18
🎩Agent 301 Puzzle | Sept 1 🧩Cards in Order:15:4:12:13 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7082 · 31.08.2025 г., 15:09
🎩Agent 301 Puzzle | Aug 31 🧩Cards in Order:8:13:1:4 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7075 · 30.08.2025 г., 14:07
🎩Agent 301 Puzzle | Aug 30 🧩Cards in Order:6:11:5:10 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7073 · 29.08.2025 г., 20:16
🎩Agent 301 Puzzle | Aug 29 🧩Cards in Order:5:14:10:12 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7055 · 27.08.2025 г., 09:50
🎩Agent 301 Puzzle | Aug 27 🧩Cards in Order:2:3:10:5 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7050 · 26.08.2025 г., 16:28
🎩Agent 301 Puzzle | Aug 26 🧩Cards in Order:12:6:5:13 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags
@WinPath · Post #7040 · 24.08.2025 г., 18:30
🎩Agent 301 Puzzle | Aug 24 🧩Cards in Order:5:15:11:4 ⚠️ Follow the sequence above to match perfectly! ❓How to Play: 1. Open @Agent301 2. Go to “Games” → “Puzzle” 3. Enter the combo and win! 🔥 Good luck and have fun! 🔔Subscribe 👉Join Agent301 ➖➖➖➖➖➖➖➖➖➖ #Agent301#DailyPuzzle
Hashtags