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

Резултати

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

Пребарај: #easternconference

当前筛选 #easternconference清除筛选
Crypto M - Crypto News

@CryptoM · Post #65087 · 10.04.2026 г., 23:24

🚀 Polymarket Sees Significant Bet on Hornets vs. Pistons NBA Game A notable transaction has occurred on Polymarket regarding the NBA regular season game between the Charlotte Hornets and the Detroit Pistons. According to Odaily, an account with a 43% win rate, identified by the address 0xe0f01e5ce19e71138a1fc77d3b466f50b7f3bad3, has purchased $200,000 worth of shares predicting a Hornets victory at an average price of 66 cents. The game between the Hornets and Pistons began today at 7 a.m. UTC+8. As the NBA regular season nears its conclusion, the Hornets hold a record of 43 wins and 37 losses, placing them 9th in the Eastern Conference. Meanwhile, the Pistons lead the Eastern Conference with 58 wins and 22 losses. #Polymarket#NBA#Hornets#Pistons#SportsBetting#Basketball#EasternConference

Crypto M - Crypto News

@CryptoM · Post #65329 · 12.04.2026 г., 23:24

🚀 NBA Regular Season: Magic Lead Celtics at Halftime In the Polymarket prediction event for the NBA regular season game between the Orlando Magic and the Boston Celtics, a user with significant earnings of over $1.8 million has invested more than $370,000 on the Magic to win with a 10.5-point spread at an average opening price of 57.9¢. Additionally, the user placed $30,000 on the Magic to win with a 12.5-point spread at an average opening price of 52¢. According to Odaily, the game, which started at 6 a.m. UTC+8, is currently at halftime with the Magic leading 61-52. Today marks the final day of the NBA regular season, with the Magic holding a record of 45 wins and 36 losses, placing them 7th in the Eastern Conference. The Celtics, with a record of 55 wins and 26 losses, are ranked 2nd in the Eastern Conference. #NBA#OrlandoMagic#BostonCeltics#Polymarket#basketball#EasternConference#MagicLead#NBARegularSeason#sportsbetting#halftime

Crypto M - Crypto News

@CryptoM · Post #64783 · 09.04.2026 г., 23:05

🚀 High-Stakes Bet on Bulls vs. Wizards NBA Game A significant wager has been placed on the Polymarket prediction platform regarding the NBA regular season game between the Chicago Bulls and the Washington Wizards. According to Odaily, an account with a history of over $4.3 million in losses has invested $150,000 on the Bulls to win against the Wizards with a 5.5-point spread, at an average opening price of 56 cents. Additionally, the same account has placed a $40,000 bet on the Bulls to win with a 6.5-point spread, at an average opening price of 50.9 cents. The NBA regular season game between the Bulls and the Wizards commenced today at 7 a.m. UTC+8. As the season nears its conclusion, the Bulls hold a record of 30 wins and 49 losses, placing them 12th in the Eastern Conference. Meanwhile, the Wizards have a record of 17 wins and 62 losses, ranking 15th in the Eastern Conference. #HighStakesBet#BullsVsWizards#NBA#Polymarket#ChicagoBulls#WashingtonWizards#NBASeason#Betting#SportsBetting#PointSpread#BasketballBetting#EasternConference