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

Резултати

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

Пребарај: #payment

当前筛选 #payment清除筛选
LOOTERS WORLD ™

@LOOTERS_WORLD7 · Post #8181 · 10.03.2026 г., 08:55

SUPPER COIN https://refer.supercoinpay.com/#/rs/jWRdhr4snF NEWBIE REWARD 200RS MIN BUY 100RS MIN SELL 100RS #PAYMENT NOT VERIFIED 🥰😘😘

Hashtags

djangoproject

@djangoproject · Post #511 · 29.11.2017 г., 13:59

http://www.djangocrew.com/blog/payment-gateway-stripe-django/ Stripe #Payment gateway integration in #Django. What is Stripe payment gateway? Stripe builds a set of products that make it extremely easy to start and operate an online business. At the core of this is payment processing. However, many other adjacent utilities come into play.

Bots Channel

@BotsChannel · Post #137 · 04.01.2016 г., 11:44

✳️BOTS | PAYMENT API✳️ Telegram to roll out Inline Bots. Payment coming soon? As Telegram's bot platform becomes increasingly important for the young messenger network, Telegram now takes it one step further: Users can now interact with bots even if they are not part of an existing chat (including group chats). Is this already part of Telegram's upcoming payment platform? Telegram payments are currently being tested in Russia. Monetizing bots and eventually the platform itself could possibly be achieved through payments handled through Telegram. However, handling payments requires a cooperation with a bank at some point. In Russia, where payments are currently being tested, the local online bank Tinkoff is bringing mobile payments to Telegram users through its @MoneyTalkBot. However, it is currently unclear when and if international payments will be available to all Telegram users. via https://orat.io/blog/telegram-to-roll-out-inline-bots-payment-coming-soon/ #bots#updates#payment

NEWS 鏈新聞-ABMedia

@abmedia_news · Post #24139 · 26.04.2026 г., 13:30

【🚀 商業應用|日本閃電網路支付新創 UseBitcoin 宣佈銷售額達 1 億日圓 】 #UseBitcoin#Payment#BTC 📍 請見報導: https://abmedia.io/usebitcoin-uses-lightning-network-reach-100-million-yen-sale 📍 訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

UXLINK

@uxlink_community · Post #477 · 13.05.2025 г., 02:19

🌍 Spend $UXLINK Globally with @CwalletOfficial! Your crypto isn’t just an asset—it’s your everyday currency. 💰 We’re expanding the #UXLINK#PayFi ecosystem with @CwalletOfficial and global partners to empower 1.4M+ $UXLINK holders and 50M+ registered users to use crypto for daily spending—from groceries to global transactions. No borders, no hassle. 🌐💳 This is the future of finance, built for your lifestyle. Join the movement to make crypto living seamless. ❤️ #Web3#payment

⚡️Uchinchi qabul imtihonidan muvaffaqiyatli o‘tgan va talabalikka tavsiya etilgan talabgorlar shartli ofertaga binoan kafolat to‘lovini to‘lashi talab etiladi. ✅Kafolat pulini to‘lovchilar uchun qulaylik yaratish maqsadida Pay me ilovasi orqali to‘lash imkoniyati yaratildi. Buning uchun siz havola orqali kirib, o‘zingiz haqingizdagi ma’lumotlarni va oferta raqami (namuna: F-123)ni kiritishingiz kerak bo‘ladi. 🔁English ➖➖➖➖➖➖➖➖➖➖➖➖➖➖ #qabul_2023#shartli_oferta#payment#PayMe ⬇️Biz ijtimoiy tarmoqlarda: Veb-sayt | Telegram | Instagram | Facebook

UXLINK

@uxlink_community · Post #438 · 17.04.2025 г., 23:35

🌍 UXLINK FujiCard KYC testing is kicking off in multiple countries! We’re currently running KYC process trials with amazing #UXLINKfam volunteers in Japan, Korea, Singapore, Indonesia, Vietnam, Nigeria, Pakistan, Bangladesh, South Africa, and across the Middle East. 🙌 Your enthusiasm and support have been incredible—shoutout to everyone helping our product and engineering teams fine-tune this across the globe! This progress brings us one step closer to launching our #UXLINK#PayFi system: FujiPay/FujiCard—on track for the first half of this year! ⏰💳 But here’s the vision: FujiCard isn’t just a card—it’s the most socialized virtual crypto card ever built. 🌟 We’re bridging the physical and digital worlds, making payments as seamless as chatting with friends—because finance should be inclusive, intuitive, and interconnected. 🌐💫 Our goal? To become the WeChat Pay/Line Pay of the blockchain world—a gateway where everyday users can spend, earn, and connect globally, all while leveraging the power of decentralized finance. 🌍💰 Stay tuned as we build a future where finance is social, borderless, and ready for everyone. The revolution starts with you. Let’s make every transaction a step toward a more connected world! 🚀✨ #Web3#payment

Crypto M - Crypto News

@CryptoM · Post #64939 · 10.04.2026 г., 11:14

🚀 AI Integration Enhances Payment Efficiency Artificial intelligence is being utilized to streamline payment processes, ensuring transactions are completed seamlessly with each interaction. According to PANews, this advancement goes beyond simply enabling AI to handle payments; it focuses on making every AI interaction an opportunity to settle financial transactions efficiently. This development highlights the growing role of AI in financial technology, aiming to enhance user experience by automating and simplifying payment procedures. #AI#Payment#FinTech#Automation#Efficiency#UserExperience#ArtificialIntelligence

Venture Village Wall 🦄

@venturevillagewall · Post #3609 · 21.12.2024 г., 08:00

Disrupting Subscription Models A startup aimed at transforming content purchasing models could emerge as a billion-dollar company. Current subscription systems frustrate users who prefer one-time access without ongoing commitments. With over 70% of subscribers dropping off within 3-6 months, creators are hesitant to implement one-time payment options, as they often yield lower revenue. However, innovation in this area could change the game. For more details, visit FastFounder. #Startup#Subscription#Content#Innovation#Revenue#BusinessModel#Fintech#CustomerExperience#Payment#MarketTrends

Crypto M - Crypto News

@CryptoM · Post #65370 · 13.04.2026 г., 02:55

🚀 Hong Kong Adopts Cautious Approach to Stablecoin Regulation Hong Kong's Financial Secretary, Paul Chan, announced on April 13 that the region will adopt a cautious approach to stablecoin regulation by initially issuing a limited number of licenses. According to BlockBeats, applicants must demonstrate practical application scenarios before further licenses are considered, allowing for experience to be gathered and evaluated. Chan emphasized the need to balance encouraging financial innovation with risk management, including the establishment of anti-money laundering regulatory mechanisms. He highlighted that while stablecoins offer decentralization and efficiency, they should be viewed primarily as payment tools rather than investment instruments. In light of the current international and security environment, Chan stressed the importance of vigilance. Hong Kong aims to enhance its financial market competitiveness and global influence as a form of proactive defense. The government and financial institutions have already established a comprehensive, cross-market monitoring system to ensure market stability. #HongKong#Stablecoin#Regulation#FinancialInnovation#RiskManagement#AML#Payment#GlobalFinance#MarketStability