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

Резултати

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

Пребарај: #gateiostartup

当前筛选 #gateiostartup清除筛选
Walken.io - Announcement

@walken_channel · Post #244 · 23.07.2022 г., 14:09

🤑Gate.io Startup Answer & Earn @walken_io💵 📝Take the quiz about Walken(WLKN) & Split a $3,000 mega prize!🏆 ⏰Ends at 9:00AM, Jul 25th (UTC) *How to participate: ✅ Join GateioOfficialNews and Walken community ✅Follow @Gateio_Startup & RT the 👉POST 🔛 Click 👉HERE to Participate now Learn More:https://www.gate.io/startup #Gateio#gateiostartup

BYIN Channel

@byinchan · Post #122 · 07.09.2024 г., 06:48

📣Startup Voting Campaign #4 - $8,000 up for grabs Vote for your favorite project by 6:00 AM, Sep 8 (UTC)! 🏆Winning projects will shine in the spotlight! 💎$BYIN$CEC$MAK$ANS 🔄Share to rally support for your pick! 👉Vote:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5 #GateioStartup#Memecoins#Airdrop

BYIN Channel

@byinchan · Post #111 · 05.09.2024 г., 15:25

📣Day 3 of voting! $8,000 up for grabs—vote for your favorite project by 6:00 AM, Sep 8 (UTC)! 🏆Winning projects will shine in the spotlight! 💎$BYIN$CEC$MAK$ANS 🔁Share to rally support for your pick! 👉Vote:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5 #GateioStartup#Memecoins#Airdrop

BYIN Channel

@byinchan · Post #106 · 04.09.2024 г., 09:48

🚀$8,000 up for grabs! #Vote for your favorite project by 06:00 AM, Sep 8 (UTC)! $BYIN$CEC$MAK$ANS 🏆Winning projects get the spotlight 🔁Retweet to support your pick Vote now:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5 #GateioStartup#Memecoins#Airdrop

Holdcoin Channel

@Holdcoin_Channel · Post #309 · 11.12.2024 г., 12:59

📣Gate.io #StartupMining Initial Offering:HoldCoin (HOLD) ❇️Total Rewards: 73,333,333 $HOLD ❇️Estimated APR: 1241% 1⃣Stake $USDT & $GT from 01:00pm, Dec 11 (UTC) https://www.gate.io/startup-mining/HOLD?pid=111 2⃣Stake $HOLD and $GT from 01:00pm, Dec 16(UTC) https://www.gate.io/startup-mining/HOLD?pid=112 3⃣Stake $HOLD and $GT from 01:00pm, Dec 26(UTC) https://www.gate.io/startup-mining/HOLD?pid=113 📈Trading Starts: 13:00pm, Dec 16 (UTC) More:https://gate.io/announcements/article/41542 #Gateio#GateioStartup#Farming

Your Own Ads

@yourownads · Post #190 · 12.02.2025 г., 12:09

📈#Gateiopartner carnival: the main prize of $12,000 is being played out 🔥 The promotion is active until 11:00 Moscow time on February 24 ℹ️How to earn: 1) Registration on Gate + KYC2 2) Go here and click "Join now" 3) We complete the tasks: 🎁BONUS 1 : Registration + KYC, PrizeStartup voucher for 20 shares 🎁BONUS 2 : Make a deposit of $50, prize from $5 to $10 🎁BONUS 3 : Make a trading volume of $200, split the prize pool of $10,000 depending on the share in the total trading volume 🎁BONUS 4 : Invite users and share the prize pool of $2000 🔗Join now and earn: https://gate.io/fr/campaigns/396?ref=VLJMULHBVA #Gateio#GateioStartup#Crypto

Your Own Ads

@yourownads · Post #149 · 06.01.2025 г., 20:26

🚀Gate.io Startup Free Offering: Cat Gold Miner (CATGOLD) 🗓Subscription Period:06:00AM January 7 - January 9 (UTC) 💵Airdrop Amount: $50,000 CATGOLD 👉Sign up here 🔗 ⏰Trading Starts:10:00,AM January 9 (UTC) 📚Full Details:Click here 🎉Gate.io New Year Red Envelope: Get a $60 bonus by following this link ➜ Red Envelope ⚡️Don’t miss this unique chance to accelerate your earnings with CATGOLD! Places are limited, register now and be among the first to take advantage of this exclusive offer! ⭐️ 🔗gate.io 📈 #GateioStartup#Gateio#CATGOLD

Your Own Ads

@yourownads · Post #187 · 08.02.2025 г., 16:29

💰Trade $HQ on Gate.io & Win Your Share of $4,000! 👀 A new trading event is live on Gate.io, giving you the chance to earn big rewards! 🗓Event Period: February 7 at 06:00 AM UTC - February 12 at 06:00 AM UTC 💰Rewards: ✅$3,000 Trading Bonus – Trade at least $50 in HQ and share a $3,000 prize pool. ✅$950 New User Bonus – New users who sign up and trade $10 in HQ will receive $10 instantly. ✅$50 Lucky Reward – 1 lucky participant from the comments will win $50! ⚠️Important: ✔️ Complete your identity verification before the event ends to qualify. ✔️ Rewards will be distributed in HQ within 14 working days. ✔️ No multiple accounts or fraudulent activity allowed. 🔥Join now and start trading! Don’t miss your chance to win big! 🔗Sign up & start trading here: https://www.gate.io/signup/?ref_type=103 #Gateio#GateioStartup#StartupMining#Launchpool#Launchpad