У строки в Python есть два очень похожих метода. На столько похожих что кажется они делают одно и тоже.
Это метод isdigit() и isnumeric()
Давайте посмотрим зачем нам два одинаковых метода? И так ли они одинаковы?
Очевидно что isdigit() говорит нам, состоит ли строка только из чисел 0-9
>>> '12'.isdigit()
True
>>> '12x'.isdigit()
False
>>> '-12'.isdigit()
False
>>> '12.5'.isdigit()
False
Можно предположить что isnumeric() делает более глубокий анализ и распознаёт в строке float или отрицательное число.
>>> '15'.isnumeric()
True
>>> '-15'.isnumeric()
False
>>> '15.2'.isnumeric()
False
Нет, всё так же как и с другим методом. В чем же тогда разница? Для начала посмотрим следующие примеры:
>>> '5'.isdigit(), '5'.isnumeric() # Обычная цифра 5
# True, True
>>> '꧕'.isdigit(), '꧕'.isnumeric() # Яванская 5
# True, True
>>> '෩'.isdigit(), '෩'.isnumeric() # Синхала 3
# True, True
>>> '৩'.isdigit(), '৩'.isnumeric() # Бенгальская 3
# True, True
>>> '༣'.isdigit(), '༣'.isnumeric() # Тибетская 3
# True, True
>>> '³'.isdigit(), '³'.isnumeric() # 3 верхний индекс (степень)
# True, True
>>> '𝟝'.isdigit(), '𝟝'.isnumeric() # Математическая двойная 5
# True, True
>>> '๔'.isdigit(), '๔'.isnumeric() # Тайская 4
# True, True
>>> '➑'.isdigit(), '➑'.isnumeric() # 8 в круге
# True, True
А теперь примеры в которых, по мнению Python, результаты не равны
>>> '¾'.isdigit(), '¾'.isnumeric() # дробь три четверти
# False, True
>>> '⅕'.isdigit(), '⅕'.isnumeric() # дробь одна пятая
# False, True
>>> '𒐶'.isdigit(), '𒐶'.isnumeric() # клинопись 3
# False, True
>>> '三'.isdigit(), '三'.isnumeric() # 3 из унифицированной идеограммы
# False, True
>>> '⑩'.isdigit(), '⑩'.isnumeric() # цифра 10 в круге
# False, True
>>> 'Ⅳ'.isdigit(), 'Ⅳ'.isnumeric() # Римская 4
# False, True
>>> '𑇪'.isdigit(), '𑇪'.isnumeric() # Сенегальская архаическая 10
# False, True
>>> '𐌢'.isdigit(), '𐌢'.isnumeric() # Этрусская цифра 10
# False, True
>>> 'ↂ'.isdigit(), 'ↂ'.isnumeric() # Римская цифра 10000
# False, True
>>> '〇'.isdigit(), '〇'.isnumeric() # Символ ККЯ ноль
# False, True
Получается, что isdigit() говорит нам, является ли символ десятичной цифрой или спецсимволом, имеющим цифирное значение после преобразования.
В свою очередь isnumeric() включает все дополнительные символы юникода которые имеют отношения к числовым и цифровым представлениям.
Ну и пара примеров в которых в обоих случаях символ не является числом, это эмодзи.
>>> '🕙'.isdigit(), '🕙'.isnumeric() # эмодзи 10 часов
# False, False
>>> '7️⃣'.isdigit(), '7️⃣'.isnumeric() # эмодзи 7
# False, False
Также есть еще один дополнительный и весьма полезный метод isdecimal().
Он нам сообщает, можно ли из указанного символа сделать простую десятичную цифру. То есть сработает ли метод int(x)
>>> '෩'.isdecimal(), int('෩') # Синхала 3
# True, 3
>>> '➑'.isdecimal(), int('➑') # 8 в круге
# False, ValueError
Какие выводы?
🔸 При определении цифры в строке isdigit() подходит лучше чем isnumeric(), но оба не гарантируют успешную конвертацию в int
🔸 Для однозначного определения возможности преобразования строки в int лучше подходит метод isdecimal()
🔸 Для однозначного определения символов 0...9 лучше использовать regex
Полный список символов юникода которые определяются как numeric
#basic
⚠️ The Satoshi-era #Bitcoin whale transferred its remaining 40,192 $BTC ($4.83B) to #GalaxyDigital in the past 6 hours.
In just 3 days, this whale has offloaded a total of 80,202 $BTC ($9.54B) at an average price of $118,950.
These coins were held for over 14 years, when $BTC traded between $0.78 and $3.37.
Follow @spotonchain for more updates now!
https://x.com/spotonchain/status/1946050652448456937
The Satoshi-era #Bitcoin whale moved its remaining 40,192 $BTC ($4.76B) to a new wallet again ~7 hours ago.
Just 2 days ago, this OG sent 40,009 $BTC ($4.71B) to #GalaxyDigital and later to exchanges when $BTC was around $117,685. The price dipped to $115,967 within 12 hours.
How long will the whale hold this time? Follow @spotonchain for more updates!
https://x.com/spotonchain/status/1945761330327392310
Lookonchain | ꘜ
A wallet (0xcaC1) linked to #GalaxyDigital deposited 125M $USDC into #Hyperliquid in the past 2 days.
They then bought $ETH, $HYPE, $BTC, $PUMP and $FARTCOIN spot, while shorting $BTC, $ETH, $DOGE, $PUMP, $FARTCOIN and $S for hedging.
https://hypurrscan.io/address/0xcaC19662Ec88d23Fa1c81aC0e8570B0cf2FF26b3
🚨 Is a BIG #BITCOIN SELL-OFF taking place?
Over the past 9 hours, #GalaxyDigital deposited 11,910 $BTC ($1.39B) to multiple exchanges.
These BTCs likely originated from the Bitcoin OG that offloaded 80,202 $BTC ($9.54B) at an average of $118,950 between July 15–18.
Notably, on July 15, Galaxy Digital had already sent 2,000 $BTC ($236M) directly to #Bybit and #Binance.
The price of $BTC dropped ~2% in 24H.
Follow @spotonchain and track the sell-off at https://x.com/spotonchain/status/1948616924004581614
A whale has deposited 10,128 $ETH, worth $20.44M, into #GalaxyDigital and #FalconX, facing a loss of $44.2M.
Initially, the whale withdrew 17,836 $ETH, worth $79.77M, from #OKX and still holds 7,709 $ETH, worth $15.13.
https://intel.arkm.com/explorer/address/0x793791549fdDD177E3Fbb2FCD3f55b3553556d37
https://x.com/OnchainLens/status/2019438045171458074
Follow @onchainlens for more onchain updates
Lookonchain | ꘜ
This mysterious institution created another 2 wallets and accumulated 33,402 $ETH($158M) in the past 3 hours.
Over the past 10 days, they have accumulated 379,317 $ETH($1.8B) from #FalconX, #GalaxyDigital, and #BitGo.
https://etherscan.io/address/0x0c3b2812364cbef85b821796da7a606ce7aed40e
Lookonchain | ꘜ
What a crazy accumulation!
This mysterious entity created 10 new wallets in the past 8 days and accumulated 312,052 $ETH($1.34B) from #FalconX, #GalaxyDigital, and #BitGo.
https://etherscan.io/address/0x0c3b2812364cbef85b821796da7a606ce7aed40e
Lookonchain | ꘜ
This mysterious institution created another 2 wallets and accumulated 44,999 $ETH($194M) in the past hour.
Over the past 7 days, they have accumulated 266,165 $ETH($1.15B) from #FalconX, #GalaxyDigital, and #BitGo.
https://etherscan.io/address/0x22d9a74dcedc4ff9a591253281a5f0ac2e2c0f1d#internaltx
https://etherscan.io/address/0xe17c55424000a20f43dddc1e949620b499f35a8c
https://x.com/lookonchain/status/1954702379905089804
Lookonchain | ꘜ
This mysterious institution accumulated another 49,533 $ETH($212M) today.
Over the past week, they have accumulated 221,166 $ETH($946.6M) from #FalconX, #GalaxyDigital, and #BitGo.
https://x.com/lookonchain/status/1953700941779112348
🚨🚨 A total of 28M $MATIC ($20.8M) was deposited to exchanges ~6hrs & 5hrs ago, including:
- 20M $MATIC ($14.9M) from whales 0xfef and 0x0b9, to #Binance.
- 8M $MATIC ($5.94M) from #Alameda Research to #OKX and #Coinbase.
Notably,
- All of the above depositors received $MATIC from the #Polygon Ecosystem Growth.
- Whales 0xfef and 0x0b9 were the Top 1 and 4 receivers in the $MATIC distribution that took place on Nov 15 (12 days ago).
- Overall, 43 addresses have deposited 145.6 $MATIC ($124M), or 67% of the Nov 15's distribution, to #Binance, #Coinbase, #OKX, #Bitfinex, and #GalaxyDigital OTC so far.
👉 More details: https://platform.spotonchain.ai/signal-details/alameda-research-and-whales-moved-matic-to-exchanges-8397
🚨#FTX and #Alameda Research moved out $23.59M worth of 19 assets to #Binance, #Coinbase, #OKX, #GalaxyDigital OTC in the past 4 days, including:
• 3,150 $ETH ($6.8M)
• 59.6M $ALEPH ($6.41M)
• 3.60M $CRV ($2.48M)
• 33,388 $AVAX ($990K)
• 50,282 $LINK ($848K)
and $6.07M worth of 14 other assets $PUNDIX, $RSR, $DOGE, $BCH, $CHR, $AXS, $MATIC, $UNI, $ORBS, $FXS, $DOT, $GMT, #1INCH, and $SOL.
In total, FTX and Alameda Research have deposited around $591M worth of 74 tokens to exchanges since October 24.
👉 More details: https://platform.spotonchain.ai/signal-details/ftx-and-alameda-research-moved-out-19-assets-10693
🚨🚨 Five addresses deposited 21.68M $MATIC ($16.09M) to #Binance via GSR Markets in the past 4 hours.
- Notably, these $MATIC all came from the distribution by #Polygon Ecosytem Growth 9 days ago.
📕 Overall, 41 addresses have deposited 125.6M $MATIC ($109M), or 57.8% of the distribution, to #Binance, #Coinbase, #OKX, #Bitfinex, and #GalaxyDigital OTC.
⚠️ Moreover, Polygon Ecosystem Growth transferred 15.64M $MATIC ($11.9M) to Alameda Research ~4hrs ago.
- Note that the #FTX and #Alameda just deposited 22.6M $MATIC ($17.2M) to #Coinbase and #FalconX ~3 days ago.
👉 More details: https://platform.spotonchain.ai/signal-details/distribution-receivers-further-deposited-matic-to-binance-8095