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

Резултати

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

Пребарај: #swap

当前筛选 #swap清除筛选
TONlines – News

@tonlines · Post #7520 · 18.11.2025 г., 20:07

swap.coffee: Halloween Event Wrap-Up #DeFi#swap The channel swap.coffee successfully concluded its Halloween Event with great participation and strong on-chain activity, turning it into a dynamic DeFi experience. Prizes for participants have already been distributed as per the winner list. Source: link @tonlines

Hashtags

GSM-панорама

@GSM_panorama · Post #536 · 07.01.2025 г., 05:10

Самым лёгким телефоном с сенсорным дисплеем по версии Книги Рекордов Гиннесса является вот этот малыш - sWaP Nova. Вес гаджета всего 40,3 грамма. Но, со своими функциями он вполне справляется – используя sWaP Nova можно звонить и отправлять SMS. Многим он, конечно же, наверное и не знаком, но в Книге Рекордов он засветился 💪 Завтра расскажу про самый тонкий смартфон в мире по версии Книги Рекордов Гиннеса. Ваши предположения, это.. ?? )) #sWaP #телефоны_рекордсмены

TONlines – News

@tonlines · Post #7524 · 19.11.2025 г., 12:05

⚡️swap.coffee: $LAMBO Trading Competition Announcement #LAMBO#swap swap.coffee presents an exciting $LAMBO trading competition with a prize pool of $2,500. Participants can trade on swap.coffee or @swapi between November 19 and 21. Top traders and random participants have chances to win various prizes in $LAMBO and Lunar Snake Onyx Black gifts. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7426 · 28.05.2025 г., 18:28

swap.coffee: Results from Trading Competition with TONCO #TONCO#swap swap.coffee announces the conclusion of the Trading Competition with a total swap volume reaching $17,832,164. Rewards are now available for participants, including special prizes for 10 random users with significant swap contributions. Full details and participant lists are accessible through their provided link. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7289 · 20.05.2025 г., 11:18

⚡️swap.coffee: Exciting TONCO Trading Competition #swap#TONCO The swap.coffee channel has launched a trading competition in collaboration with TONCO, a pioneering DEX platform on TON. Participants can win rewards by trading through TONCO on swap.coffee, with opportunities to earn Vintage Sigare Telegram gifts and a share of $2,000 USDT. The competition runs until May 28. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7016 · 01.05.2025 г., 18:08

⚡️swap.coffee: Impressive April 2025 Metrics #swap#metrics Swap.coffee shared its growth metrics for April 2025, showing a transaction volume of nearly $18 million, 37,129 transactions, and 5,934 unique users. The team expresses gratitude for the ongoing support from their community. Source: link @tonlines

🆕New Mission is Live! Make a swap and complete the basic security quiz to earn rewards! 🥇 ➡️NFTs from the previous mission have already been sent. ➡️The streaks were added so you can track how many missions you've completed in a row. Stay tuned for more updates in the Swap section coming soon! 😏 🔥Keep mining HOT! #web3#hotwallet#swap#NFT

TONlines – News

@tonlines · Post #7163 · 11.05.2025 г., 17:24

⚡️Swap.coffee: Instant Rewards and Staking Opportunities #swap#staking#XROCK Swap.coffee offers a unique and efficient staking experience, allowing users to claim their rewards instantly. Currently, a prize giveaway is available for staking $XROCK with friends from @XRocket. Tokens available for staking include CES, XROCK, JETTON, and DFC. Source: link @tonlines

TONlines – News

@tonlines · Post #7410 · 28.05.2025 г., 12:16

⚡️swap.coffee: Torch Finance Integrated #Torch#Finance#swap swap.coffee has integrated Torch Finance as a new liquidity source. This integration enhances swap.coffee users' experience by providing optimized routes for trading liquid staking tokens, stablecoins, and yield-bearing tokens. Source: link @tonlines

⚡️Storm Trade x🏴‍☠️MyTonWallet: Trading Tournament with $2,500 Prize Pool! Storm Trade Launches Joint Event with MyTonWallet — $2,500 in $STORM Tokens at Stake. How to participate? • Exchange $STORM in MyTonWallet • Gain volume — it is automatically taken into account in the rating • Get into the top 100 and get a share of $2,500 in $STORM 🗓Tournament dates: April 14 -- 29 💎Bonus from MyTonWallet: each participant of the contest will be credited with cashback in $MY. And when staking $MY the exchange fees are lower. 😉 🏆Follow the leaderboard, improve your positions and get your reward! #Swap#Contest#MY#STORM

Alexa Mods

@itsmealexaliza · Post #1152 · 19.03.2025 г., 05:03

🚀 SWAP - No ROOT v4.6.1 [Premium] 🚀 🔹 Boost Your Device Performance! 💾 Create swap files to expand RAM without root access! ⚡ Improve multitasking & gaming performance easily. 🔒 Safe & user-friendly – no complex setup required. ✨ Premium Features Unlocked! ✅ No Ads ✅ Faster Swap Creation ✅ Optimized Performance 📥 Download Now: 📢 Join our tech community for updates! #SWAP#NoRoot#PerformanceBoost#AndroidTools

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