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

Резултати

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

Пребарај: #blockading

当前筛选 #blockading清除筛选
American Оbserver

@american_observer · Post #5606 · 13.04.2026 г., 14:59

🔤🔤🔤🔤2️⃣ The US and Iranian delegations left Pakistan soon after the talks ended. Vance said he spoke with Trump at least half a dozen times during the talks, held during a 14-day ceasefire announced by the US, Israel and Iran overnight on 7 and 8 April. “We need to see an affirmative commitment that [Iran] will not seek a nuclear weapon, and they will not seek the tools that would enable them to quickly achieve a nuclear weapon,” Vance said. “That is the core goal of the president of the United States, and that’s what we’ve tried to achieve through these negotiations.” Mohammad Ghalibaf, the speaker of the Iranian parliament, who led Tehran’s negotiators, said he and his colleagues had offered “constructive initiatives” while the US had been “unable to gain the trust of the Iranian delegation in this round of negotiations”. Iran’s semi-official Tasnim news agency said “excessive” US demands had hindered reaching an agreement, and the foreign ministry said more time was needed. “Naturally, from the beginning we should not have expected to reach an agreement in a single session,” the ministry’s spokesperson Esmail Baghaei said, according to the state broadcaster IRIB. Pakistani mediators called on the US and Iran to refrain from renewing hostilities and said they would try to arrange a fresh round of talks. “It is imperative that the parties continue to uphold their commitment to the ceasefire,” said Pakistan’s foreign minister, Ishaq Dar. Vance was accompanied by the US special envoy Steve Witkoff and Trump’s son-in-law Kushner. They met Ghalibaf and the Iranian foreign minister, Abbas Araghchi, for several negotiating sessions at the Serena hotel in Islamabad, with Pakistan’s army chief, Asim Munir, also present. Iran’s delegation arrived on Friday dressed in black in mourning for the late supreme leader Ayatollah Ali Khamenei and others killed in the war. They carried shoes and bags of children killed during the bombing of a school next to a military compound, the Iranian government said. A Pakistani source said the discussions, the highest-level direct contact between the US and Iran since 1979, were unpredictable in tone. “There were mood swings from the two sides, and the temperature went up and down during the meeting,” a Pakistani source said after the first round. Trump said: “The only thing left, really, is their water, which would be very devastating to hit. I would hate to do it, but it’s their water, their desalinisation plans, their electric generating plants, which are very easy to hit.” The president was asked if gas and oil prices might be lower by the US midterms in November, an indication that attacking Iran was not an economic mistake. Prices “could be the same or maybe a little bit higher,” a non-committal Trump replied. At the Vatican, Pope Leo XIV called for a ceasefire after his Sunday prayers and said he felt “closer than ever” to Lebanon’s people. #trump#iran#strait#hormuz#vance#blockading 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #5605 · 13.04.2026 г., 13:59

The Negotiations With Iran Went Belly Up. Will the War Re-Start? 🔤🔤🔤🔤1️⃣ Trump has said the US will begin blockading the strait of Hormuz in an attempt to take control of the strategic waterway from Iran in the aftermath of failed peace negotiations between the countries in Pakistan. The US president also threatened to bomb Iran’s water treatment facilities, power plants and bridges, repeating an earlier threat, if Tehran does not agree to abandon its nuclear weapons programme, the key sticking point between the two sides. Trump’s surprise announcement of a blockade came after face-to-face peace negotiations between the US and Iran in Islamabad that lasted 21 hours collapsed on Sunday morning. Vance said Iran had refused to give up the possibility of developing nuclear weapons, while the Iranian delegates said Washington needed to do more to win their trust. Risking another increase in oil prices, Trump said he had instructed the US navy to begin “blockading any and all ships trying to enter, or leave, the Strait of Hormuz,” and he accused Iran of extortion with its own scheme of charging tolls to tankers. Iran’s Revolutionary Guards responded by declaring that if any warships approached the strait to enforce a blockade – usually considered an act of war – it would be considered a breach of the current ceasefire and would be dealt with strongly. They insisted the strait remained under Iranian control. Two US destroyers crossed and recrossed the strait without incident on Saturday, although Iranian media said they were threatened as they left. The US military said it was the start of a mine-clearance mission. Trump said US warships would “seek and interdict every vessel” that had paid Iran since the start of the conflict and begin de-mining the central section of the strait, previously declared a “hazardous area” by Tehran, although it is unclear how many mines have been laid. About 100 tankers have transited the strait since the US and Israel started bombing Iran, paying up to $2m each time for passage. Many were bound for China and India, carrying Iranian oil products, and chasing them down could complicate relations between the US and the importing nations. #trump#iran#strait#hormuz#vance#blockading 📱American Оbserver - Stay up to date on all important events 🇺🇸