Заметка начинающим, которые часто сталкиваются с подобной непоняткой.
Ситуация следующая, есть список файлов:
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
⚖️Warm welcome to Nomis’ ecosystem – meet TONBanking as our strategic partner!
TONBanking is a decentralized Fintech DeFi platform accessible through a Telegram web app. It provides Telegram users with B2B/B2C service consisting of various tools: virtual cards, gift cards, KYC, acquiring, exchange and more.
As we, here at Nomis, believe and adhere to the pillars of #decentralization, so TONBanking conduct all txs, integrations, DAO voting, dividend payouts, and other activities directly on the TON blockchain via smart contracts. This structure allows the system to operate without jurisdictional limitations 🔐
What's the next stop of Nomis x TONBanking partnership? Stay tuned for fascinating use-cases of leveraging Nomis as a Protocol within the partners’ app!
Stay tuned, turn on notifications, and follow us for further announcements 🔔
🧠 Vitalik: Ethereum Is Built for Freedom, Not Convenience
Vitalik Buterin 強調,Ethereum 從一開始就不是為了「快、便宜、好用」而設計,而是為了「自由、抗審查、韌性」而存在。
#Ethereum#Web3#以太坊#Decentralization#Crypto
———
全文+分析 👇🥇資源搜索群🖲️👆
他原話直指核心:
“This is the game Ethereum is suited to win.”
翻成白話就是:
當世界進入高監管、高衝突、高政治風險時代,
ETH 才是最適合生存的系統。
不是工具鏈,
是制度級底層架構。
❓你認為未來最需要「抗審查」的是哪一塊?
A|資金轉移
B|言論資訊
C|身份系統
D|全部都需要
👇⭐️👇
🤣👇留言你的判斷 👇
🎙💫 This Thursday, we’re thrilled to be joining in on a Twitter Space with OpenDataforWeb3, the builder community DAO fighting for data #decentralization🌐
We'll be chatting about all things #data & KYVE's impact on the space. Set a reminder! ⏰⤵️
https://twitter.com/KYVENetwork/status/1661004134991142912
🤔 Want to create your own dashboard for visualizing #NFT data?
The KYVE Academy has a NEW course, giving you hands-on experience in using KYVE’s trustless data, Data Pipeline, AirbyteHQ,Elasticsearch, & Kibana to do just that!
Try it out 🧑💻⤵️
https://twitter.com/KYVENetwork/status/1660926166411223041
New academy course ⤴️
🌐Explore the Unique Features of Mappasaurus That Set Us Apart!🦖
🗺At Mappasaurus, we’re not just another mapping tool. We integrate cutting-edge technology and user-focused features to provide a mapping experience like no other. Here’s what makes us stand out:
🧠Advanced AI Integration:
🟠Predictive Analytics: Our AI doesn’t just map your route; it predicts future conditions to optimize your journey in real-time.
🟠Customized User Experience: Mappasaurus learns from your preferences and habits, tailoring its functionality to meet your specific needs.
🌿Decentralized Mapping Contributions:
🟢Community-Driven Data: Every user is an integral part of our map-making process. Your contributions directly influence the accuracy and richness of our maps, making them more reliable and comprehensive.
🟢Transparent Updates: See the impact of your contributions as our maps evolve with community input.
🏦Enhanced Privacy and Security:
✅Data Protection: We
prioritize your privacy with advanced encryption and anonymization techniques, ensuring that your data and location details are secure.
✅No Third-Party Sharing: Your information stays with us; we don’t sell data to third parties.
Why Mappasaurus❓
🔴 Join a platform that respects user input, protects your data, and uses AI to enhance your navigation experience. With Mappasaurus, you’re part of a community that’s shaping the future of mapping.
💡 Discover more about our innovative features and join the mapping revolution!
#Mappasaurus#InnovativeMapping#AI#Decentralization#PrivacyFirst
Will Bitcoin reach $100,000 before July 2026?
Markets aren’t just opinions they’re signals.
EdgeMarket turns global sentiment into structured prediction markets where the crowd, data, and AI converge.
Watch the signal form in real time.
What do you think?
#EdgeMarket
#PredictionMarkets
#Bitcoin
#CryptoMarkets
#AI
#Decentralization
#TON
#MarketSignals
#FutureOfMarkets
Bitcoin's Nation State Adoption Threat Insights
Andreas Antonopoulos revisits concerns about nation state adoption of Bitcoin. Highlights the risks of government intervention impacting Bitcoin’s decentralization and the broader cryptocurrency ecosystem. Importance of maintaining Bitcoin’s integrity emphasized amid evolving regulations. For detailed insights, check the full explainer link.
#Bitcoin#Crypto#VC#Decentralization#Regulation#Adoption#Governments#Security
Geopolitical questions rarely move markets when they become obvious.
They move when probability starts shifting before formal signals appear.
That is why prediction systems matter.
Not because they claim certainty, but because they surface how conviction changes while narratives are still forming.
At EdgeMarket, we study how distributed judgement reacts to emerging geopolitical scenarios long before consensus hardens.
The important signal is rarely the headline itself.
It is how probability changes before the headline arrives.
#EdgeMarket#PredictionMarkets#Geopolitics#AI#MarketIntelligence#Decentralization#GlobalRisk#DecisionIntelligence
Hey there, fellow freedom fighters! 🚀⚡
Imagine Nostr leveling up with custom NIPs that let us plug in ANY crypto we want. $XMR for ultimate privacy, $TON for seamless Telegram vibes, or whatever floats your boat. And don't forget stacking Bitcoin + Lightning Network ⚡ with Cashu ecash for that unbreakable privacy layer!
This is how we build unstoppable finance, censorship-resistant social media, decentralized identity, and true non-KYC freedom tech. No more chains just pure sovereignty! Who's ready to make it happen? 🔥
Join the resistance: t.me/DanishCryptoDK | npub1c3gyzcvf2xakqy4vy06umu7hgpr97ttyp05yrlvmk8g8xvmse57qj286r6
#PrivacyMatters#Nostr#XMR#TON#Bitcoin#Lightning#Cashu#Decentralization#FreedomTech
Hey there, fellow freedom fighters! 🚀⚡
Imagine Nostr leveling up with custom NIPs that let us plug in ANY crypto we want. $XMR for ultimate privacy, $TON for seamless Telegram vibes, or whatever floats your boat. And don't forget stacking Bitcoin + Lightning Network ⚡ with Cashu ecash for that unbreakable privacy layer!
This is how we build unstoppable finance, censorship-resistant social media, decentralized identity, and true non-KYC freedom tech. No more chains just pure sovereignty! Who's ready to make it happen? 🔥
Join the resistance: t.me/DanishCryptoDK | npub1c3gyzcvf2xakqy4vy06umu7hgpr97ttyp05yrlvmk8g8xvmse57qj286r6
#PrivacyMatters#Nostr#XMR#TON#Bitcoin#Lightning#Cashu#Decentralization#FreedomTech
Vitalik Buterin on AI's Role
Vitalik Buterin emphasizes AI as a human-controlled tool in his latest article. This framework aims to align technological advancements with human values and needs, reducing the risks of centralized power. He highlights the importance of decentralized systems like blockchain for maintaining diverse and quality decision-making.
#AI#Blockchain#Decentralization#Technology#HumanValues#Control#Innovation#Ethics#Crypto#VC