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

Резултати

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

Пребарај: #conferenceondisarmament

当前筛选 #conferenceondisarmament清除筛选
Russian MFA 🇷🇺

@MFARUSSIA · Post #28492 · 25.02.2026 г., 17:03

🎙Statement by Russian Permanent Representative to the UN Office in Geneva Gennady Gatilov at the high-level segment of the Conference on Disarmament (February 24, 2026, Geneva) 📄Read in full Key outtakes: • The current session of the Conference on Disarmament takes place against the background of rapidly deteriorating situation in the field of international security and strategic stability. • The situation in Ukraine is a result of the policy of Western countries which for a long time have cultivated anti-Russian sentiments in Ukraine, fostered hatred for Russia and everything Russian, suppressed Russian language, history and culture, engaged in the military development of its territory and increased the supplies of long-range weapons to the Kiev regime. • Russia has always advocated for a negotiated settlement of Ukrainian crisis. At the same time, the dialogue should be based on an equal and mutually respectful basis, where an ultimate goal is to establish a long-term peace with respect for the legitimate interests of all States and nations living in this region instead of a short truce. • The ongoing tensions in the Middle East could have devastative consequences for both regional and global security. The Israeli-US attacks on Iran’s peaceful nuclear facilities, which were placed under the #IAEA safeguards, have become a serious blow to the nuclear non-proliferation regime. • The existing contradictions around the Iranian nuclear program can only be resolved through politico-diplomatic means. In this regard, we welcome the resumption of the bilateral dialogue between Washington and Tehran. • We note with regret that against the background of deteriorating international security environment and persistent tensions in the military-strategic sphere the US rejected the constructive Russian initiative inviting the parties to the #NewSTART Treaty to commit officially to voluntary self-limitations to keep the quantitative ceilings specified in the Treaty following its expiration. • Currently, a limited group of countries undermines the system of agreements in the field of arms control, committing numerous violations of the fundamental imperatives of the UN Charter, such as equality, respect of sovereignty, non-interference in internal affairs, the resolution of disputes through dialogue. • We assign the Conference on Disarmament a crucial role in strengthening the international security architecture through elaborating multilateral legally binding agreements on arms control, disarmament and non-proliferation. The development of an international legally-binding instrument on the prevention of an arms race in outer space remains a constant priority for the Russian Federation. • Against the background of the current international instability our common goal is to ensure sustainability of the Treaty on the Non-Proliferation of Nuclear Weapons. As a depository State of the NPT, Russia strictly adheres to its “letter and spirit”. We attach particular importance to the upcoming 11th NPT Review Conference, which takes place in April-May 2026. • Russia, as depositary State of the Biological and Toxin Weapons Convention, advocates for the comprehensive strengthening of its regime, including through the adoption of a legally binding protocol to the BTWC with an effective verification mechanism. • Given the continuing threats of the use of chemical substances and biological agents as weapons by terrorists, the Russian initiative to develop at the Conference on Disarmament an international convention for the suppression of acts of chemical and biological terrorism is more relevant than ever. #ConferenceOnDisarmament