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

Резултати

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

Пребарај: #21shares

当前筛选 #21shares清除筛选
SpotOnChain | Announcement

@spotonchain · Post #1005 · 23.10.2024 г., 03:52

🇺🇸 Spot ETF: 🔴$79.1M to $BTC and 🟢$11.9M to $ETH 🗓️ Oct 22, 2024 👉#21Shares (ARKB) experienced the largest outflow since its inception yesterday, causing the overall net flow for the 11 BTC ETFs to turn negative after 7 days with strong inflows. 👉 However, BlackRock (IBIT) continued to add another 637 $BTC ($43M) to its holdings. Follow @spotonchain and check out the latest updates about #Bitcoin and #Ethereum#ETFs via https://platform.spotonchain.ai/en/signal-details/us-bitcoin-and-ethereum-etf-net-inflows-update-on-october-22-2024-197369

SpotOnChain | Announcement

@spotonchain · Post #1024 · 20.11.2024 г., 10:53

🇺🇸 Spot ETF: 🟢$829.2 to $BTC and 🔴$81.3M to $ETH (final) 🗓️ Nov 19, 2024 👉 The net flow for BTC ETFs surged strongly as the BTC price recorded a new all-time high following the launch of the BTC ETF options. 👉#21Shares (ARKB) recorded the largest inflow since launch yesterday, surpassing the previous high of $203M on Sep 27. 👉#BlackRock continued to see inflow for BTC ETF and outflow for ETH ETF. Follow @spotonchain and check out the latest updates about #Bitcoin and #Ethereum#ETFs via https://platform.spotonchain.ai/en/signal-details/us-bitcoin-and-ethereum-etf-net-inflows-update-on-november-19-2024-223516

SpotOnChain | Announcement

@spotonchain · Post #1014 · 05.11.2024 г., 05:16

⚠️U.S. BTC ETFs faced a record $540.9M outflow just before the election—the second largest ever! Notably, #21Shares (ARKB) and #Bitwise (BITB) had their largest outflows since launch. Meanwhile, #BlackRock (IBIT) was the only ETF with an inflow of 569 $BTC ($38.6M). Last week (Oct 28–Nov 1), BTC ETFs saw a massive $2.22B net inflow over 4/5 days, while ETH ETFs had a $13M net inflow on 3/5 days. 👉 Details: https://x.com/spotonchain/status/1853663826723717611

NEWS 鏈新聞-ABMedia

@abmedia_news · Post #24577 · 13.05.2026 г., 12:33

【💰 交易市場|21Shares 推出首檔 Hyperliquid ETF,上市首日吸金 120 萬美元】 #21Shares#Hyperliquid#CryptoETF 21Shares 於 5/12 推出 $HYPE ETF,成功將去中心化交易所資產引入美國市場。 基金代碼 $THYP 首日獲 120 萬美元淨流入,成交總額則達 180 萬美元。James Seyffart 指其表現優於平均,預期 Bitwise 隨後接棒。 📍閱讀全文: https://abmedia.io/21shares-hyperliquid-etf-launch-day 📍 訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

SpotOnChain | Announcement

@spotonchain · Post #1021 · 15.11.2024 г., 04:35

🇺🇸 Spot ETF: 🔴$399.6M to $BTC and 🔴$3.1M to $ETH 🗓️ Nov 14, 2024 👉 This is the 3rd-largest net outflow ever for the 11 US BTC ETFs. 👉 Both #21Shares (ARKB) and #Bitwise (BITB) recorded new largest outflows since launch, surpassing previous lows of $138.3M and $79.8M, respectively, on Nov 4. Follow @spotonchain and check out the latest updates about #Bitcoin and #Ethereum#ETFs via https://platform.spotonchain.ai/en/signal-details/us-bitcoin-and-ethereum-etf-net-inflows-update-on-november-14-2024-218273

SIGNAL

@finsignal · Post #3116 · 21.05.2024 г., 11:51

The financial giant #Fidelity has made edits to its application to launch the spot #Ethereum#ETF, removing the stacking from there. Previously, #ARK#21Shares also made a similar change The current deadlines for applications for the #Ethereum#ETF are shown in the picture.

SpotOnChain | Announcement

@spotonchain · Post #949 · 08.08.2024 г., 04:04

🚨 US #ETF 07 AUG: 🟢$45M to $BTC and 🔴$24M to $ETH 🌟 BTC ETF UPDATE (final): +$45M • The net flow turned positive again after 3 days of being strongly negative! • #BlackRock (IBIT) had the largest inflow of the day at $52.5M. • #Fidelity (FBTC) and #21Shares (ARKB), however, have had non-positive flow for 14 consecutive trading days. 🌟 ETH ETF UPDATE (final): -$24M • The net flow turned negative again after 2 days of being positive. • #Grayscale (ETHE) continued to see a smaller outflow. • However, 6 out of the other 8 US ETH ETFs also had smaller inflows yesterday. Follow @spotonchain and check out the latest updates about #Bitcoin and #Ethereum ETFs via https://platform.spotonchain.ai/en/signal-details/us-bitcoin-and-ethereum-etf-net-inflows-update-on-august-7-2024-158195

🇺🇸📊 以太全球新聞 📆 2025-10-08 EthereumGlobalNews |✏️ 區塊鏈網路成長對比 — ✏️#SOL vs #ETH:21Shares 發布報告指出,Solana 在同階段的表現 大幅領先以太坊。報告提到,Solana 主網上線五年後的月營收為 以太坊同期的 20~30 倍。相比之下,Ethereum 上線五年時的月收入還不到 1,000 萬美元。 #Solana#Ethereum#鏈上營收#區塊鏈成長#21Shares

Crypto M - Crypto News

@CryptoM · Post #64797 · 10.04.2026 г., 00:24

🚀 XRP Spot ETF Experiences Significant Outflow According to Odaily, data from SoSoValue indicates that on April 9, Eastern Time, the XRP spot ETF saw a net outflow of $661,200. The 21Shares XRP ETF (TOXR) was the only fund to experience this outflow, contributing to a historical total net outflow of $25.845 million. As of the time of reporting, the total net asset value of the XRP spot ETF stands at $955 million, with an XRP net asset ratio of 1.15%. The historical cumulative net inflow has reached $1.21 billion. #XRP#SpotETF#Outflow#Cryptocurrency#21Shares#TOXR#NetAssetValue#CryptoNews

Venture Village Wall 🦄

@venturevillagewall · Post #4257 · 27.02.2025 г., 07:00

First Solana ETF Approved in USA 🚀 First Solana ETF ($SOL) appears at DTCC, paving the way for potential approval in the US. 🟢 Key step as DTCC handles all exchange settlements. 🟢 Applications previously submitted by VanEck, 21Shares, and Bitwise. Approval could boost institutional liquidity in Solana. #Solana#ETF#Crypto#SEC#Finance#Investing#Markets#Liquidity#InstitutionalInvestors#VanEck#21Shares#Bitwise#DTCC#Trading

Crypto M - Crypto News

@CryptoM · Post #65369 · 13.04.2026 г., 02:54

🚀 XRP Spot ETFs See Significant Inflows and Outflows XRP spot ETFs experienced notable financial movements last week, with a net inflow of $11.75 million, according to Odaily. The data, sourced from SoSoValue, covers the trading days from April 6 to April 10 (Eastern Time). The Bitwise ETF XRP led the inflows, attracting $9.5154 million, bringing its historical total net inflow to $388 million. Following this, the Franklin ETF XRPZ saw a weekly net inflow of $2.8987 million, with its historical total reaching $324 million. Conversely, the 21Shares ETF TOXR recorded the highest net outflow, amounting to $661,200, with its historical total net outflow standing at $25.85 million. As of the latest update, the total net asset value of XRP spot ETFs is $968 million, with an ETF net asset ratio of 1.16% compared to XRP's total market capitalization. The cumulative historical net inflow has reached $1.22 billion. #XRP#ETFs#Crypto#Inflow#Outflow#Bitwise#Franklin#21Shares#NetAssetValue#MarketCap

12
ПретходнаСтраница 1 од 2Следна