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

Резултати

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

Пребарај: #riyadh

当前筛选 #riyadh清除筛选
Addis Standard

@addisstandardeng · Post #21167 · 23.01.2026 г., 13:13

#UAE abruptly cuts aid to vital hospitals after withdrawing from #Yemen The sudden exit of the United Arab Emirates (UAE) from Yemen early this month came with a decision to end years of humanitarian support for key hospitals, abruptly cutting off access to specialised healthcare for many Yemenis. The UAE withdrew its forces after its separatist allies, the Southern Transitional Council, were routed in southern Yemen as #Riyadh sharply opposed the Emirati role in the #STC’s seizure of territory under the control of the Saudi-backed government. UAE-funded hospitals played a vital role for Yemenis after more than a decade of conflict had damaged public health infrastructure and left many unable to afford private healthcare. Patients from far and wide sought these these facilities in search of high-quality, free healthcare. Many undertake long journeys to access specialised surgeries... https://web.facebook.com/AddisstandardEng/posts/pfbid07VH6x99PAkGsbTnAkN2FrHgamxE1MamXC2iwAk5cbJWG28AQzAKzEzvqysmTuBfFl

Addis Standard

@addisstandardeng · Post #21402 · 14.02.2026 г., 07:12

News: #Eritrean president meets #Saudi deputy FM in Asmara following #Riyadh– #Addis diplomatic engagements President Isaias Afwerki of Eritrea held talks with Waleed bin Abdulkarim Al-Khereiji, Deputy Foreign Minister of Saudi Arabia, during a meeting in Asmara, according to Eritrea’s Ministry of Information. The meeting, held Thursday at the Denden Guest House, focused on strengthening longstanding bilateral relations and expanding cooperation across political, economic, security, cultural, and social sectors. The information ministry said discussions also covered shared perspectives on regional and international developments, including the role of Red Sea littoral states in maintaining regional peace and stability. Eritrea’s Foreign Minister Osman Saleh attended the talks alongside senior Saudi officials... https://www.facebook.com/share/1GDQjadMAW/

Addis Standard

@addisstandardeng · Post #21025 · 09.01.2026 г., 12:38

#Saudi_Arabia moves to rein in #UAE after Yemen exposes rivalry Saudi Arabia is moving to end the role of the United Arab Emirates in #Yemen and diminish its neighbor’s influence in other arenas, including the Red Sea, as tensions rise in the longstanding rivalry between the two Gulf powerhouses. After ordering the UAE to withdraw troops from Yemen and bombing a shipment of weapons it said Abu Dhabi was delivering to secessionists, #Riyadh is now looking to bring all UAE-backed factions in the deeply divided country under its control, according to two people briefed on the situation. The two OPEC+ members have jockeyed for influence in the war-torn, strategically located nation for years. The fallout between the #Arab world’s two biggest economies — and key American allies — will have repercussions far beyond Yemen. It could impact efforts to contain Iran and ensure the Gaza ...... https://web.facebook.com/AddisstandardEng/posts/pfbid02znoqYaEtyk1HsgV2jV9vdRBHHaCpT4SHqC4TrcpopGsqj4KupLe7ZnQRghdcsYvLl

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3965 · 04.02.2025 г., 04:38

Saudi Crown Prince Mohammed bin Salman received the appointed Syrian President Abu Mohamad al-Jawlani and his accompanying delegation upon his arrival at Al-Yamamah Palace in the Saudi capital, Riyadh. This was al-Jawlani’s first trip abroad since ousting the former regime. #Syria#SaudiArabia#Riyadh#MBS#AlJawlani

Addis Standard

@addisstandardeng · Post #21377 · 12.02.2026 г., 07:28

News: #Saudi Foreign Minister visits Addis Abeba a week after Gedion’s #Riyadh trip; talks focus on regional security and stability #Saudi_Arabia’s Minister of Foreign Affairs, Prince Faisal bin Farhan bin Abdullah, has arrived in #Addis_Abeba for an official visit, as #Ethiopia and Saudi Arabia step up diplomatic engagement centered on bilateral ties, regional security, and migration-related issues. According to a press release from Saudi Arabia’s Ministry of Foreign Affairs, the visit is aimed at discussing developments in the region and efforts to enhance regional security and stability. Prime Minister #Abiy Ahmed, who met with Prince Faisal, said he held “productive discussions on a broad range of bilateral and multilateral issues,” noting that talks focused on strengthening longstanding ties, expanding cooperation across key sectors, and enhancing coordination on regional and global matters of mutual interest........ Read more: https://addisstandard.com/?p=55154

Addis Standard

@addisstandardeng · Post #21034 · 10.01.2026 г., 09:29

#Yemeni southern separatists in #Riyadh announce disputed disbanding of #STC -The STC, which #SaudiArabia says is backed by the #UAE, launched an offensive against Yemeni gov’t troops in December. Yemen’s main southern separatists ‍have decided to disband following talks in Saudi Arabia, the secretary-general of the organisation has said, although the announcement was dismissed by its spokesman, who called it “ridiculous”. The Southern Transitional Council (STC) Secretary-General Abdulrahman Jalal al-Subaihi said in a broadcast on Yemeni television on Friday that the dissolution of the group was taken to preserve peace and security in the south and in neighbouring countries. He praised “the measures taken by the Kingdom of Saudi Arabia and the solutions it has provided that meet the needs of the people of the South”. https://www.aljazeera.com/news/2026/1/9/yemens-separatist-southern-transitional-council-announces-its-dissolution

Addis Standard

@addisstandardeng · Post #21858 · 27.03.2026 г., 08:01

News: #Saudi ‘freezes’ reported arms deal for #Sudan’s army, signals possible policy shift #Saudi_Arabia has reportedly frozen an arms deal intended to supply forces loyal to General Abdel Fattah #al-Burhan through #Pakistan, in what may signal a shift in #Riyadh’s approach to the ongoing conflict in Sudan. According to a report by Africa Intelligence, the move reflects growing skepticism within Saudi circles over al-Burhan’s reliability as a long-term partner, as the war continues and Sudan’s political and military landscape becomes increasingly fragmented. The report indicates that Riyadh may be recalibrating its position toward backing a political process aimed at establishing a civilian-led government, rather than pursuing military support that could further prolong the conflict. Read more: https://addisstandard.com/?p=56093

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #4188 · 25.03.2025 г., 04:13

Lebanese daily @alakhbarnews reported that #SaudiArabia remains firm in its stance, maintaining economic pressure on #Lebanon. According to visitors to #Riyadh, the kingdom has conveyed that it will not contribute "a single penny" to Lebanon’s reconstruction efforts. Well-informed sources indicate that President #JosephAoun indirectly received this message during his meeting with Saudi Crown Prince #MohammedbinSalman earlier this month. Additionally, he was reportedly met with a firm Saudi refusal to lift the travel ban on its citizens visiting Beirut. During their discussions, bin Salman reportedly questioned Aoun on whether he could guarantee the safety of Saudi nationals traveling along Beirut’s airport road, which is lined with images of #Hezbollah and Iranian leaders. He remarked, “At the very least, remove the pictures.” Upon his return, Aoun relayed this request to Speaker of Parliament #NabihBerri, inquiring about the possibility of reducing the number of such images along the route. Why do you think Saudi Arabia cares about images displayed in another country? Share your thoughts with Hoopoe.

#SaudiArabia#Riyadh#desert#flood#weather#climate#destruction#anomaly#climatechange 🇸🇦Наводнение в пустыне после сильных дождей 🌧🌊🏜 28 марта 2026 года проливные дожди превратили пустынные районы вблизи Эр-Рияда (Саудовская Аравия) в бушующие потоки воды. Редкое явление: песчаные ландшафты были затоплены, а вода быстро распространилась по пустынной местности.