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

Резултати

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

Пребарај: #irassg

当前筛选 #irassg清除筛选
IRAS

@irassg · Post #1752 · 13.10.2025 г., 09:44

This workshop was the culmination of months of thoughtful preparation, deep dives, and collaboration across teams — all driven by a shared ambition to reimagine how we can serve better, adapt faster, and create greater impact for Singapore. It was inspiring to see the energy, honest reflections and collective commitment in the room. As One IRAS, we’re charting the path towards a more connected, innovative, and future-ready organisation. #lifeatiras#irassg

IRAS

@irassg · Post #1737 · 09.10.2025 г., 09:22

We also recognised the contributions of our Accredited Tax Specialists (ATS) through the Technical Contribution Award, inducted our 15 newly accredited tax specialists, and celebrated the achievements of our Book Prize winners for the Advanced Tax Programme. Thank you to the 2025 ATC Organising Committee and all who have made this event possible! 🎉 #lifeatIRAS#irassg

IRAS

@irassg · Post #1548 · 29.05.2025 г., 09:01

We kay-poh and asked our colleagues what they do at IRAS 👀 Psst: it’s not all about taxes! Swipe to see some of the different roles we have here ➡️ Explore the roles available at go.gov.sg/lifeatiras #LifeatIRAS#irassg

IRAS

@irassg · Post #1528 · 09.05.2025 г., 09:19

What does a UI/UX Designer at IRAS do? Watch as our colleague's children take a guess at what she does for work, while she shares her thoughts on balancing work and motherhood. Wishing all the incredible mothers out there a Happy Mother's Day! 💐❤️ #irassg#lifeatIRAS

IRAS

@irassg · Post #1520 · 08.05.2025 г., 09:02

You heard it here first! IRAS is more than just Singapore's tax authority - we're a community of passionate individuals contributing to Singapore’s growth and progress. Join us today at go.gov.sg/lifeatiras #irassg#lifeatiras

IRAS

@irassg · Post #1867 · 25.11.2025 г., 10:34

Less than a week until the YA 2025 Corporate Income Tax filing deadline. All companies are reminded to file their YA 2025 Corporate Income Tax Return (Form C-S/ Form C-S (Lite)/ Form C) at mytax.iras.gov.sg by 30 Nov 2025. #irassg#CorporateIncomeTax2025

IRAS

@irassg · Post #1863 · 24.11.2025 г., 11:46

Looking for the perfect match this Corporate Income Tax season? Let’s find your “wholly and exclusive” matches. Swipe right on the deductible expenses and swipe left on non-deductible expenses! Reminder: File your YA 2025 Corporate Income Tax returns by 30 Nov 2025 Learn more: go.gov.sg/businessexpenses #CorporateIncomeTax2025#irassg

IRAS

@irassg · Post #1861 · 20.11.2025 г., 08:45

Even if your company has been steeping in dormancy mode all year, just like cold brew tea slowly steeping in the fridge... you still need to file your YA 2025 Corporate Income Tax Return for your Dormant Company, unless you have obtained a waiver to file the return. Reminder: filing of the YA 2025 Form C-S, Form C-S (Lite) or Form C by 30 Nov 2025 is compulsory for all companies. Find out how to file as a dormant company or how to apply for a waiver at go.gov.sg/irasdormantcompanies #CorporateIncomeTax2025#irassg

IRAS

@irassg · Post #1493 · 07.04.2025 г., 09:13

When you (girl-)bossed too hard that you have to pay taxes 🌟 If your total annual net trade income was over $6,000 (or your total taxable income exceeded $22,000) last year, remember to include your passion projects in your tax filing by 18 April! Learn more about tax obligations for online sellers and service providers at go.gov.sg/tax-guide-online-sellers-service-providers More at go.gov.sg/taxseason2025 #TaxSeason2025#irassg

IRAS

@irassg · Post #1477 · 28.03.2025 г., 06:04

Have you filed your income tax return yet? Remember to do so by 18 Apr. Avoid these common mistakes: 1. Not filing your income tax return when you need to 2. Incorrect relief claims 3. Incorrect expense claims 4. Not clicking the “submit” button 5. Not informing IRAS when you discover mistakes in your submission Check out our handy e-Filing Guide if you are unsure of your tax filing: go.gov.sg/efilingguide More at go.gov.sg/taxseason2025 #TaxSeason2025#irassg

IRAS

@irassg · Post #1403 · 25.02.2025 г., 06:40

As IRAS' Group Tax Specialist, Richard supports his team in reviewing tax compliance matters and complex issues. He also provides training and consultations on IP valuation as an IP Valuation Specialist. Recently, Richard was appointed as Tax Academy's Specialist & Curriculum Development Specialist. In this role, he develops training programmes for tax professionals, equipping them with relevant and practical insights whilst fostering collaboration within the tax community. Read on to discover how Richard's diverse roles complement one another in his daily work. #irassg#irasfam#lifeatiras

IRAS

@irassg · Post #1368 · 28.01.2025 г., 02:03

Transforming how we do taxes: DON-API is one of IRAS’ ongoing efforts to partner with our tax ecosystem to make taxpaying easier and more seamless. Meet the all-girls team from IRAS behind this game-changing initiative. Find out more at https://www.iras.gov.sg/who-we-are/what-we-do/annual-reports-and-publications/taxbytes-iras/engagement/making-tax-submission-simple-for-ipcs #lifeatiras#irassg#irasfam

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