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

Резултати

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

Пребарај: #indiarussia

当前筛选 #indiarussia清除筛选
Маниш Кумар 🇷🇺🇮🇳

@manishkumar_ru · Post #115 · 21.08.2025 г., 17:46

🇮🇳🤝🇷🇺 Strengthening India–Russia Trade On August 18, we hosted a business meeting at the Moscow Chamber of Commerce and Industry with the FICCI delegation. ✔ Bilateral trade has reached $67B — discussions at Innoprom 2025 aim to expand it to $100B. ✔ Opportunities for India in energy, manufacturing, agriculture, and textiles. ✔ Addressing the trade imbalance and exploring a Rouble–Rupee exchange mechanism. Recently, I shared India’s perspective on RBK TV after the US imposed a 25% duty on Indian goods: > “India, as the world’s 4th largest economy, has the right to protect its strategic sovereignty.” A strong Indian business presence in Moscow reflects our shared commitment to deeper economic cooperation. #IndiaRussia#Trade#FICCI#MCCI#SoltexGroup

Маниш Кумар 🇷🇺🇮🇳

@manishkumar_ru · Post #92 · 07.07.2025 г., 09:00

🇷🇺🤝🇮🇳 INNOPROM 2025 Update Today, I had the honor of speaking at the strategic session “Russia–India: Toward a $100 Billion Trade Turnover” at INNOPROM 2025 in Ekaterinburg. Proud to share the stage with H.E. Vinay Kumar, Andrey Sobolev, Anil Agarwal, Nikita Ryblenkov, Igor Kurzhiyamsky, Mikhail Labudin, Badiga Shrikant, and Alexander Krutov. Grateful for the opportunity to contribute to India–Russia trade dialogue as Deputy Chairman of MCCI’s India Commission & President of Soltex Group. 📍 I’m at INNOPROM till evening — happy to connect! #INNOPROM2025#IndiaRussia#SoltexGroup#ManishKumar#TradeGrowth#EAEUIndia

Маниш Кумар 🇷🇺🇮🇳

@manishkumar_ru · Post #88 · 27.06.2025 г., 12:42

🇷🇺🤝🇮🇳 I’m pleased to share that I will be participating as a speaker at INNOPROM 2025, Russia’s largest international industrial trade fair, taking place from July 7–10 at the Ekaterinburg-EXPO. On July 7 (10:30–12:00, Hall 3.4), I will speak in the strategic session: “Russia–India: Toward a $100 Billion Trade Turnover.” As President of Soltex Group and Deputy Chairman of the MCCI Commission on Foreign Economic Relations with Partners in India, I look forward to contributing to the dialogue on expanding bilateral trade, addressing non-tariff barriers, and advancing the EAEU–India Free Trade Agreement. INNOPROM is a premier global platform where industry, innovation, and international cooperation converge — bringing together decision-makers from around the world. 🔗 Register: expo.innoprom.com/registration/visitor-2025 🎟 Promo Code: ZVCZ2A (Free Entry) Let’s build the next chapter of India–Russia industrial partnership. #INNOPROM2025#SoltexGroup#ManishKumar#IndiaRussia#EAEUIndia#TradeGrowth

Маниш Кумар 🇷🇺🇮🇳

@manishkumar_ru · Post #123 · 21.08.2025 г., 17:57

Sealing the Partnership in Moscow 🇮🇳🤝🇷🇺 We are pleased to witness a significant milestone in India-Russia relations, as EAM Dr. S. Jaishankar and Russia's Deputy Prime Minister Denis Manturov signed the Final Protocol after high-level talks in Moscow. This development further strengthens bilateral cooperation, opening doors for trade, partnerships, and joint ventures across multiple sectors. At Soltex Group, we view this as a promising step towards expanding our presence in Russia and fostering new opportunities for businesses. 📌 Interested in exploring business opportunities between India and Russia? Connect with us — we’re here to support and guide you. #IndiaRussia#TradeRelations#SoltexGroup#BusinessOpportunities#BilateralTrade#Partnership