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

Резултати

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

Пребарај: #commerce

当前筛选 #commerce清除筛选
Venture Village Wall 🦄

@venturevillagewall · Post #4187 · 19.02.2025 г., 04:00

Crypto-Friendly Lutnick Confirmed as Commerce Secretary The US Senate has confirmed Howard Lutnick as Secretary of Commerce, known for his pro-crypto stance. In related news, State Street and Citi, two major banks, are both entering the cryptocurrency custody business, with State Street planning to launch services next year. State Street manages $46.6 trillion while Citi holds $25 trillion in custody assets. Read more here and further details on custody here. #Crypto#Commerce#Banking#Custody#HowardLutnick#StateStreet#Citi#Finance#Assets#Investment#DigitalAssets#BitCoin#CustodianServices#Blockchain#Senate#Regulation#USPolitics#Cryptocurrency#Innovation#CryptoNews

GitHub Trends

@githubtrending · Post #15100 · 29.08.2025 г., 11:30

#typescript#commerce#e_commerce#javascript#marketplace#marketplace_solution#medusa#medusajs#medusajs_v2#multi_vendor#multi_vendor_ecommerce#multivendor_ecommerce#nodejs#open_source#shopping_cart Mercur is a free, open-source platform that lets you build and run your own multi-vendor marketplace with full control over your data, infrastructure, and customizations. It combines the ease of SaaS with the freedom of open source, so you avoid transaction fees and vendor lock-in. Built on modern MedusaJS technology, Mercur supports both B2C and B2B marketplaces, offering customizable storefronts, admin and vendor panels, and integrations like Stripe for payments. This means you can create a unique, scalable marketplace tailored to your business needs without relying on costly or restrictive platforms. It requires some technical skill but gives you complete ownership and flexibility. https://github.com/mercurjs/mercur

Venture Village Wall 🦄

@venturevillagewall · Post #4186 · 19.02.2025 г., 01:00

Howard Lutnick Named Secretary of Commerce Pro-Bitcoin advocate Howard Lutnick confirmed as U.S. Secretary of Commerce. By Q4 2024, 1,576 firms invested in U.S. spot Bitcoin ETFs, totaling $26.8bn AUM (+113%). Institutional investments rose to 25.4% of AUM, up from 21.3% in Q3, propelled by high IBIT activity. More details here: watcher Guru #Bitcoin#ETF#Finance#Investing#HowardLutnick#Commerce#InstitutionalInvesting#IBIT#Crypto#AUM#USA#ProBitcoin#MarketTrends#InvestorInterest#Q42024#WallStreet#CryptoNews#Regulations#DigitalAssets#VC

Venture Village Wall 🦄

@venturevillagewall · Post #3435 · 19.12.2024 г., 06:42

E-commerce Conversion Crisis E-commerce stores face a critical issue: they struggle to convert social media traffic into purchases, with conversion rates half as effective as average standards. Social media is a key source for online sales, with 64% of internet users shopping through these platforms, accounting for one-third of total online sales. The significant loss from unconverted traffic prompts stores to seek solutions, making platforms that improve conversion rates highly valuable. Learn more about a startup addressing this issue: Read here #Ecommerce#SocialMedia#Conversion#OnlineSales#Startup#Traffic#Retail#DigitalMarketing#Commerce#Business#Tech#Innovation#Sales#Marketing#UserExperience#Platforms#Shopping