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

Резултати

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

Пребарај: #tpfam

当前筛选 #tpfam清除筛选
TokenPocket

@tokenpocket_channel · Post #1738 · 01.01.2026 г., 09:00

🎆 Happy New Year! #TPFam We wish you glowing health, top-tier security for all your assets, and a market that stays eternally bullish. 🌕 May this year bring you boundless prosperity and exciting opportunities in crypto!

Hashtags

TokenPocket

@tokenpocket_channel · Post #1256 · 02.03.2024 г., 14:53

💥Big Congrats! #TPFam 🏆Check if you are on the PFPAsia NFT Whitelists Giveaway Winner List!👇 https://docs.google.com/spreadsheets/d/1Nx66DZYX768_CETOgCFXi8QRK9jXp5cvP0Np4LOzPk4/edit#gid=0 🟥 Check your RED👇 https://whitelist.pfp.asia 🔴For more details, follow PFPAsia.

Hashtags

TokenPocket

@tokenpocket_channel · Post #1163 · 30.01.2024 г., 09:21

💥Big Congrats! 🏆Check if you are on the 500 $NOAH Giveaway Winner List! (200 Winners) ​Noah_DeFi 👉 https://docs.google.com/spreadsheets/d/1LpNzHNqPW6PJD2fcqIWuteLWhBWguX9H4Tyti740ym4/edit#gid=0 🎁The rewards will be distributed by ​Noah_DeFi within A week! 💙Thanks for your participation! #TPFam If you have any questions, you can join TokenPocket's Telegram to get more info. 👉https://t.me/tokenPocket_en 【Details】https://twitter.com/TokenPocket_TP/status/1752260036150358373 【Powered By】Crypto Box

Hashtags

TokenPocket

@tokenpocket_channel · Post #1753 · 22.01.2026 г., 06:59

🌊 2025 has been a year filled with growth, challenges, and continued progress. To our #TPFam — your support has powered every step forward. 💙 Thank you for building and growing with TokenPocket. Dive into the #TokenPocket 2025 Annual Report 👇 https://tokenpocket-gm.medium.com/tokenpocket-2025-annual-report-7820b638a1d1 https://x.com/TokenPocket_TP/status/2013901810453410143?s=20

TokenPocket

@tokenpocket_channel · Post #1186 · 05.02.2024 г., 07:06

With the unwavering support from [#TPFam](https://twitter.com/hashtag/TPFam), 2023 has been a year of significant breakthroughs! 🎯 Always have a BIG Thanks in my mind and thank you for helping us make everything possible! 💙 Dive into the [#TokenPocket](https://twitter.com/hashtag/TokenPocket) 2023 Annual Report 👇 https://tokenpocket-gm.medium.com/tokenpocket-2023-annual-report-3b9bd4025f83 【Details】https://twitter.com/TokenPocket_TP/status/1754399781915631720 【Powered By】Crypto Box

TokenPocket

@tokenpocket_channel · Post #1170 · 02.02.2024 г., 01:40

💥We've reached 400K+ followers! ​TokenPocket_TP Thank you for your unwavering support! #TPFam Keep building! 💪💪💪🦾🦾🦾 💙Enjoy your #TokenPocket wallet! 👉https://www.tokenpocket.pro/ 👉https://extension.tokenpocket.pro/ 【Details】https://twitter.com/TokenPocket_TP/status/1753231123315032137 【Powered By】Crypto Box

TokenPocket

@tokenpocket_channel · Post #1144 · 25.01.2024 г., 03:35

💥Big Congrats! 🏆Check if you are on the Scopechat $200 Giveaway Winner List! (20 Winners) ​ScopeProtocol 👉https://docs.google.com/spreadsheets/d/1HJmeNoN4ZLKh8fuvEadmNsHLOD-_33VjFvIW0S6pptg/edit#gid=0 🎁The rewards will be distributed by ​ScopeProtocol within A week! 💙Thanks for your participation! #TPFam If you have any questions, you can join TokenPocket's Telegram to get more info. 👉https://t.me/tokenPocket_en How to check your rewards? 🎯Download TokenPocket 👉https://www.tokenpocket.pro/ 👉https://extension.tokenpocket.pro/ ✅Check on your #TokenPocket Polygon Wallet! 【Details】https://twitter.com/TokenPocket_TP/status/1750361152532664546 【Powered By】Crypto Box

TokenPocket

@tokenpocket_channel · Post #1042 · 24.12.2023 г., 12:14

🧑‍🎄Merry Christmas! #TPFam#TokenPocketChristmas ❄️May your wallets be filled with joy, your transactions be seamless, and may the blockchain of happiness bless you with endless prosperity. Wishing you a Merry Christmas and a crypto-filled New Year! 🚀🌟 👉https://www.tokenpocket.pro/ 【Details】https://twitter.com/TokenPocket_TP/status/1738895386377601385 【Powered By】Crypto Box

TokenPocket

@tokenpocket_channel · Post #1187 · 05.02.2024 г., 07:55

💥Big Congrats! 🏆Check if you are on the 1,000 [#ZETA](https://twitter.com/hashtag/ZETA) Giveaway Winner List! (50 Winners) 👉https://docs.google.com/spreadsheets/d/1tZ2uGSZDAyX7tj_pSWCrOUwn1f_kDxHBBpJnMRjM6t0/edit[#gid](https://twitter.com/hashtag/gid)=0 🎁The rewards have been distributed, please check your [#TokenPocket](https://twitter.com/hashtag/TokenPocket) [@​zetablockchain](https://twitter.com/zetablockchain) wallet! Guide👉https://help.tokenpocket.pro/en/wallet-operation/how-to-create-a-wallet/zetachain 💙Thanks for your participation! [#TPFam](https://twitter.com/hashtag/TPFam) If you have any questions, you can join TokenPocket's Telegram to get more info. 👉https://t.me/tokenPocket_en 【Details】https://twitter.com/TokenPocket_TP/status/1754412672639193249 【Powered By】Crypto Box

TokenPocket

@tokenpocket_channel · Post #1336 · 07.05.2024 г., 09:27

💙Thanks to all the #TPFam who participated in the #TP6Anni celebration! 🏆Check if you are on the #TP6Anni Giveaway Winner List! 1️⃣ 50 BitlayerLabs Lucky Helmet NFT 👉https://docs.google.com/spreadsheets/d/1qjIkzt1_CM_LfNaoy4vVIrqSmB5hF4oAN5pIScYgeQM/edit#gid=0 2️⃣ $2,000 esMP token Giveaway 👉https://docs.google.com/spreadsheets/d/1tt_AiQmQYZk3EFS-6hEwTZFBI0iTcJDK6YD110TZeQU/edit#gid=0 3️⃣1,000 Piggy Boxes V3 Giveaway 👉https://docs.google.com/spreadsheets/d/1_Aj9cgq0SdyJHQjztl-TWGwHQb_NHgWIbaonwzSH7vA/edit#gid=0 4️⃣$3,000 $TNA and 50 Tapnames Whitelists Giveaway 👉https://docs.google.com/spreadsheets/d/1ZiCOS_nQ897Vj5p5TgoMi607hCCk2IILhwVn6-w-MjE/edit#gid=0 💙Thanks for your participation! If you have any questions, please join https://t.me/tokenPocket_en.

TokenPocket

@tokenpocket_channel · Post #1168 · 01.02.2024 г., 09:28

💥Big Congrats! 🏆Check if you are on the 1000 USDT Giveaway Winner List! (100 Winners) ​ChintaiNetwork ​ChintaiNexus 👉https://docs.google.com/spreadsheets/d/1sY-0fZgfrBZC2UQsZPKvN_Dl3V1A0nG-cR7iOpXlbcM/edit#gid=0 🎁The rewards have been distributed, please check your #TokenPocket#BNBChain wallet! 💙Thanks for your participation! #TPFam If you have any questions, you can join TokenPocket's Telegram to get more info. 👉https://t.me/tokenPocket_en 【Details】https://twitter.com/TokenPocket_TP/status/1752986641118134673 【Powered By】Crypto Box

TokenPocket

@tokenpocket_channel · Post #935 · 23.11.2023 г., 09:33

💕💕Happy #Thanksgiving! 🐔 Wishing You a Joyous Thanksgiving! Thank you for the unwavering support from #TPFam and #TokenPocket Partners! Keep Building! 🏃🏃‍♂️🏃‍♀️ 【Details】https://twitter.com/TokenPocket_TP/status/1727620906225373326 【Powered By】Crypto Box

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