TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #121 · 20 јул.

Регулярно требуется преобразовать какой-либо текст в максимально совместимый текст для URL, имени файла, имени объекта в каком-то софте и тд. Требования совместимости простые: в тексте должны быть только допустимые символы. Обычно это a-z, 0-9 и "_" или "-". То есть, только прописные буквы латинского алфавита и цифры (как пример). Допустим, нам нужно название статьи в блоге преобразовать в slug для добавления его в URL этой статьи. Как это лучше всего сделать? В Django по умолчанию есть готовая функция slugify для таких случаев. Но я её никогда не использую. Почему? Потому что её недостаточно! Приведём пример >>> from django.utils.text import slugify >>> slugify('This is a Title') 'this-is-a-title' Пока всё отлично >>> slugify('This is a "Title!"') 'this-is-a-title' Спец символы удалились, всё хорошо. >>> slugify('Это заголовок статьи') '' Вот и приехали 😢. Если текст не английский то буквы просто игнорируются. Можно это поправить >>> slugify('Это заголовок статьи', allow_unicode=True) 'это-заголовок-статьи' Но тогда мы не вписываемся в условие. У нас появилась кириллица в тексте. Так как я часто пишу сайты для русскоязычных пользователей эта проблема весьма актуальна. Я не использую стандартную функцию и всегда пишу свою. Оригинал я не беру в расчёт и пишу полностью свою функцию. И так, по порядку: 🔸1. Исходный текст: >>> text = 'Мой заголовок №10 😁!' Взял специально посложней со специальными символами. 🔸2. Транслит Необходимо сделать транслит всех символов в латиницу. Здесь очень выручает библиотека unidecode. Помимо простого транслита кириллицы в латиницу она умеет преобразовывать спец символы и иероглифы в текстовые аналоги. from unidecode import unidecode >>> unidecode("Ñ Σ ® µ ¶ ¼ 月 山") 'N S (r) u P 1/4 Yue Shan' Очень крутая библиотека, советую👍 В нашем случае получаем такое преобразование: >>> text = unidecode(text) >>> print(text) 'Moi zagolovok No. 10 !' Отличный транслит. Смайл просто удалился, хотя я ждал что-то вроде :). Ну и ладно, всë равно невалидные символы. А еще наш код уже поддерживает любой язык, будь то хинди или корейский. 🔸4. Фильтр символов Unidecode не занимается фильтрацией по недопустимым символам. Это мы делаем в следующем шаге через regex. Просто заменим все символы на "_" если они вне указанного диапазона. >>> text = re.sub(r'[^a-zA-Z0-9]+', '_', text) >>> print(text) 'Moi_zagolovok_No_10_' Символ "+" в паттерне выручает когда несколько недопустимых символов идут рядом. Все они заменяются на один символ "_". 🔸5. Slugify Осталось удалить лишние символы по краям и сделать нижний регистр >>> text = text.strip('_').lower() >>> print(text) 'moi_zagolovok_no_10' Получаем отличный slug! 😎 🌎 Полный код в виде функции. ______________ PS. Проверку что в строке остался хоть один допустимый символ я бы вынес в отдельную функцию. #libs#tricks#django

Резултати

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

Пребарај: #financing

当前筛选 #financing清除筛选
StartupBase

@startupbaseuz · Post #6342 · 06.11.2025 г., 12:01

ℹ️IT Park Capital sizning fikringizni bilmoqchi Agar siz startapni yaratayotgan yoki rivojlantirayotgan bo‘lsangiz, moliyalashtirish qanchalik muhimligini bilasiz. “IT Park Capital” hozirda startaplar va IT-kompaniyalarga haqiqatan ham qanday moliyaviy vositalar va mexanizmlar kerakligini aniqlash maqsadida so‘rovnoma o‘tkazmoqda. Biz ta’lim dasturlari va akseleratsiyadan tortib, IT-xizmatlar eksporti hamda venchur kapital vositalarigacha bo‘lgan yangi qo‘llab-quvvatlash modellarini yaratishga yordam beradigan taklif va g‘oyalarni to‘plamoqdamiz. 📩Qisqa so‘rovnomani havola orqali to‘ldiring Sizning fikringiz startaplar uchun moliyaviy infratuzilmani yaxshilash, O‘zbekiston ekotizimini yanada barqaror va o‘sish uchun ochiq qilishga yordam beradi. — ℹ️IT Park Capital wants your opinion If you are launching or developing a start-up, you know that financing is crucial. IT Park Capital is currently conducting a survey to understand what financing tools and mechanisms startups and IT companies really need. We are collecting suggestions and ideas that will help create new support models — from educational programmes and acceleration to IT service exports and venture capital instruments. 📩Fill out the short form at the link — your opinion will help improve the financial infrastructure of startups and make Uzbekistan's ecosystem more sustainable and open to growth. #Startupbase#ITParkCapital#UzbekistanStartups#Financing#TechEcosystem

Venture Village Wall 🦄

@venturevillagewall · Post #3566 · 20.12.2024 г., 09:33

Funding Societies Raises $25M Funding Societies, the leading SME digital financing platform in Southeast Asia, has successfully raised $25 million as part of their funding round on November 5, 2024. They focus on providing short-term financing solutions for SMEs and investment opportunities for investors. For more details, visit Funding Societies. #Funding#SME#Financing#Investment#SoutheastAsia#DigitalPlatform#FinanceSolutions

Crypto M - Crypto News

@CryptoM · Post #65020 · 10.04.2026 г., 14:09

🚀 AI TRENDS | CoreWeave's Junk Bonds Rise Amid Optimism from Tech Deals CoreWeave's junk bonds experienced a rise in value due to increased market optimism following transactions with several major technology companies. According to Jin10, as of 9:05 AM New York time (21:05 UTC+8), the bonds, which have a coupon rate of 9.75% and a face value of 100 cents, increased to 101.88 cents. During the syndication process, the bond's size was expanded from the initially planned $1.25 billion. Data shows that another convertible bond issued on the same day, which was also increased to $3.5 billion, has yet to begin trading. This financing round is the latest for CoreWeave and occurred just hours after the company announced a new agreement with Meta Platforms to supply AI computing products. On Friday, Anthropic agreed to lease CoreWeave's data center capacity to meet the growing demand for its AI services. CoreWeave's stock rose more than 6% during intraday trading. #AI#CoreWeave#JunkBonds#TechDeals#Financing#Meta#Anthropic#DataCenter#StockMarket#ConvertibleBonds

Crypto M - Crypto News

@CryptoM · Post #64989 · 10.04.2026 г., 13:04

🚀 AI TRENDS | Secure Blockchain Acquires Agentic Solutions in Stock Deal Secure Blockchain, a publicly traded Canadian company, has announced the acquisition of Agentic Solutions Limited, an AI Agent company based on ElizaOS, in an all-stock transaction valued at approximately $450,000, equivalent to 5 million common shares. According to Foresight News, the company also completed a private placement financing of $1.5 million, with the Eliza Foundation subscribing to about 50% of the shares, amounting to roughly $750,000. The funds raised will be allocated to AI Agent development, platform construction, and operational expenses. Additionally, Secure Blockchain settled $500,000 of debt through the issuance of approximately 4.44 million shares. Following the transaction, the total share capital stands at about 32.59 million shares, with a market value estimated at $3.67 million based on the financing price. The related shares are locked until August 11, 2026. Agentic Solutions is a commercial partner of ElizaOS, focusing on developing enterprise-level AI Agent products within this framework. ElizaOS, created by Eliza Labs, is one of the most active open-source AI Agent frameworks currently available. Secure Blockchain, previously specializing in blockchain embedded email encryption services, is transitioning into the Agentic AI sector following this acquisition. #AI#Blockchain#Acquisition#Financing#ElizaOS#AgenticSolutions#StockDeal#EnterpriseAI#OpenSourceAI#TechInvestment

Venture Village Wall 🦄

@venturevillagewall · Post #3486 · 19.12.2024 г., 13:57

Coblocks Secures $500K Funding Coblocks has successfully raised $500K in funding as of December 4, 2024. The platform offers unified tooling, instant deployment, and seamless collaboration in one streamlined solution. #Coblocks#Funding#Tech#Startup#Platform#Collaboration#Deployment#Innovation#Investment#Tools#Startups#InvestmentRound#FundingRound#Financing#Growth#Technology#Business#Software#Solutions#Digital

Venture Village Wall 🦄

@venturevillagewall · Post #3425 · 18.12.2024 г., 12:12

Databricks Secures $10B Funding Round Databricks has successfully raised $10 billion in a funding round that concluded on December 17, 2024. For more details, visit Databricks. #Databricks#Funding#Tech#Investment#Data#Cloud#Analytics#Software#BigData#Startup#Round#Financing#VentureCapital#Database#Platform#Enterprise#AI#ML#SaaS#Growth#Innovation

Venture Village Wall 🦄

@venturevillagewall · Post #4216 · 22.02.2025 г., 10:00

Bybit Hack Linked to Lazarus Group A recent analysis suggests the Bybit hack, involving ~$1.5 billion, may have been conducted by the North Korean Lazarus Group. Arkham Intelligence reports that the group likely converts ERC-20 tokens to ETH, then to BTC, possibly funding nuclear programs. Research also points to potential links with a previous attack on Phemex. Investigators note that funds were moved to wallet 0x33d0...8F65 during the laundering process. Read more: Forklog #Bybit#LazarusGroup#CyberSecurity#Blockchain#Crypto#Hacking#NorthKorea#Financing#CryptoCrime#DeFi#Ethereum#Bitcoin#ERC20#Phemex#FundsLaundering#OnChainAnalysis#ArkhamIntelligence#ZachXBT#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #3543 · 20.12.2024 г., 09:31

MRI Simulator Secures $3.5M Corsmed has successfully raised $3.50M to enhance its MRI simulator, which provides an affordable, realistic training solution for students and technicians. This technology allows hands-on experience for just 1% of the cost of traditional MRI scanners, expanding training opportunities significantly. #Corsmed#MRI#Simulator#Healthcare#Training#EdTech#Innovation#Financing#MedicalTraining#TechFunding#Startup#Students#Technicians#AffordableHealthcare#HandsOnTraining#SkillsDevelopment#Technology#Upskilling#AffordableTech#MedicalEducation