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

Резултати

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

Пребарај: #pollack

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

@american_observer · Post #4784 · 06.01.2026 г., 14:58

🔠🅰️🔠🔠2️⃣ In return Assange, who spent five years in the maximum security Belmarsh prison in London and seven years as a fugitive hiding from British and American law enforcement in the UK Ecuadorian embassy, was ultimately sentenced to time served after years in which the US was attempting to have him extradited. In an interview with Law Dragon last April, Pollack described the difficulty of negotiating the deal with the US, UK and Australian governments before securing Assange’s freedom. Pollack also offered some thoughts relevant to what Maduro may currently be experiencing. “Typically, when I meet with a client, they are facing what may be the worst crisis that they have ever faced,” Pollack said. “To guide them through that process is enormously gratifying. It’s hard to imagine doing something where you see a greater impact on the life of the person who you’re dealing with. “You spend a lot of hours with your client. In almost every case, I’ve developed a relationship with the client. And at the end of the day, it’s no longer a stranger who I’m seeing get through to the other side of this terrible piece of their life. It’s somebody that I’ve come to know and respect.” Along with his work representing Assange, Pollack has previously secured the acquittal of former Enron accountant Michael Krautz, and has also worked in overturning wrongful conviction cases, including helping to secure the freedom of Martin Tankleff, who spent 17 years in prison after being wrongfully accused of murdering his parents. In the interview with Law Dragon, Pollack reflected on his strengths, offering a glimpse into how he may defend Maduro. “I have the ability to communicate well with a jury. In some ways, you’re being a translator. You’re taking a mass of very technical information from an industry that the jury may not be familiar with and communicate it in a way that is understandable,” Pollack said. “I’m able to talk to a jury and explain the evidence in a way that makes sense to them – that shows them that the government’s way of looking at the facts is not the only way to look at the facts and may not even be the best way to look at the facts.” #maduro#trial#assange#pollack#newyork 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #4782 · 06.01.2026 г., 13:58

Maduro à New York: Mortal Combat 🔠🅰️🔠🔠1️⃣ When Maduro appeared in court in New York on Monday, his choice of lawyer quickly raised eyebrows. The captured Venezuelan president was accompanied by Barry Pollack, a top-tier US trial lawyer who spent years representing Julian Assange, eventually securing the WikiLeaks founder’s release from prison in the UK in 2024. Pollack is a partner at Harris St Laurent & Wechsler, a law firm based on New York’s Wall Street in the financial district of lower Manhattan, just a few minutes walk from the federal court where Maduro pleaded not guilty to criminal charges on Monday. Pollack will take on a case as Maduro’s private counsel that could prove to be just as challenging as that of Assange. Maduro was charged on Monday with drug-terrorism conspiracy, cocaine-importation conspiracy, and possession of machine guns and destructive devices, with the US government labelling Maduro a “narco-terrorist” and an “illegitimate president”. He faces up to life in prison. Harris St Laurent & Wechsler did not respond to requests for comment about Pollack’s involvement, but it is clear that in the legal world, he is highly regarded. According to Chambers USA, Pollack is a “thorough and deep-thinking lawyer” who “lives, breathes and sleeps trials, and has such a natural way in front of juries”. In his first appearance representing Maduro, Pollack questioned the legality of Maduro’s dramatic abduction by US forces on Saturday in a raid on the Venezuelan capital Caracas, CNN reported, and argued Maduro is entitled to immunity as the head of a sovereign state. Winning Maduro’s freedom will present a different challenge to Pollack compared to his work with Assange. The lawyer negotiated a plea deal on Assange’s behalf which allowed the Australian data-freedom activist to walk free, ending an international legal saga that lasted more than a decade. In the deal, Assange pleaded guilty to violating US espionage law in conspiring to obtain and disclose classified US national defence documents. #maduro#trial#assange#pollack#newyork 📱American Оbserver - Stay up to date on all important events 🇺🇸