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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #83 · 11 мај

У строки в 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

Hashtags

Резултати

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

Пребарај: #zealy

当前筛选 #zealy清除筛选
Airdrop Strikers™

@airdropstrikers · Post #1463 · 07.10.2023 г., 06:32

🚀 The #Zealy sprint has officially begun! 🚀 It's time to dive into action as our thrilling sprint is now underway. With a fantastic prize pool of $5,000 + 500,000 Basalt tokens, this is a journey you won't want to miss 🎉 Join us and make your mark in this exciting sprint: https://zealy.io/c/basaltcoin/questboard💰 🚀 The future is green, and BasaltCoin is leading the way! Don't miss out on the opportunity to be part of the Greentech revolution. Invest with us and make a positive impact on our planet while growing your assets🌱 💰 Basalt presale 👉https://basaltcoin.com/sale

Hashtags

Crypto Officer™

@cryptoofficer · Post #1200 · 12.10.2023 г., 19:25

📦BasaltCoin✅️ 🔥 Total Reward: $5,000 + 500,000 Basalt tokens 👑 The #Zealy sprint has officially begun! 🚀 🚧Rating: ⭐️⭐️⭐️⭐️⭐️ 🎁Joining Link :https://zealy.io/c/basaltcoin/questboard 📔Information: 🚀The future is green, and BasaltCoin is leading the way! Don't miss out on the opportunity to be part of the Greentech revolution. Invest with us and make a positive impact on our planet while growing your assets🌱💰 🌐 Presale Link: https://basaltcoin.com/sale 🔴Note:Please do your own research (DYOR) before joining to any airdrops project, also airdrop is 100% free. Don't send any fee or penny for receiving airdrop token.

Hashtags

Crypto Officer™

@cryptoofficer · Post #1238 · 23.11.2023 г., 14:21

📦 HIPP Merch Giveway ✅ 💲 Reward: 🔹1st 300 - $30 🔹 Next 700 - $20 🪙 Additional rewards: You'll also get the #BitgetPioneer role, extra #Zealy Sprint Points, and the chance to win an El Hippo x Bitget t-shirt! 🛡 Rating: ⭐⭐⭐⭐⭐ 😀Airdrop Link:https://partner.bitget.com/bg/5WHE9P ============================= ✅Steps to Participate: 🔘Signup on Bitget withthis link 🔘 Make a deposit of $50 (a net deposit, meaning $50 more than your withdrawals) from November 21 - 28. Deposit cannot be from a CEX. 🔘 Provide yout Bitget UID on our Zealy quest. ============================= 👑Let's Go:https://zealy.io/c/elhippo/questboard 🖥Information: 💎Only transfers from non-CEX wallets are eligible. 💎 It's IMPORTANT to join #Bitget using our link. 💎If you have already registered at Bitget, you can still join the airdrop 😀Note:Please do your own research (DYOR) before joining to any project, also projects are 100% free. Don't send any fee or penny for receiving any token.

Airdropp.io

@airdropp_io · Post #468 · 01.02.2024 г., 12:02

🔥 Babylon Chain Airdrop They received $18M investment. Partners with Altlayer. BTC staking platform. Zealy shared, let's join. 👉https://zealy.io/c/babylonchain/invite/y4iEQg20XJpzFcyU24YdP #babylon#airdrop#altlayer#zealy

Airdrop Strikers™

@airdropstrikers · Post #1257 · 29.05.2023 г., 21:30

Introducing #Skrimples exciting new #airdrop campaign on #Zealy🔥🔥 https://zealy.io/c/skrimples/questboard We have a massive prize pool of 1,000,000,000 $Skrimp tokens worth $4200 waiting for all the Zealy #ruffhouse hunters out there. 🔽🔽 Medium 🔉 #airdrop#giveaway#shib#pepeburn

Genius Airdrops™

@geniusairdropsss · Post #441 · 21.08.2023 г., 11:06

👑HOMERUN #Giveaway IS LIVE - 500 USDT to grab👑 Homerun team would like to showcase our appreciation for all of you guys who have been providing great support which enables us to observe extraordinary development during the last couple of months 🚀 We would like to announce the Official #Giveaway event for all of you in our community 👉Prize Pool: $500 $USDT for participants 👉Finish all the tasks in Zealy and grab the USDT 👉Event time (21/08 - 29/08) 👉Join Zealy now: https://zealy.io/c/homerun/questboard/2312ddde-0986-4991-857b-875b4af2698d #NFTGiveaway#Giveaway#AirdropCrypto#Airdrop#FreeMoney#Web3#USDT#USDTGiveaway#Zealy#QuestN