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

Резултати

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

Пребарај: #ubuntu

当前筛选 #ubuntu清除筛选
404 Information

@Info404 · Post #65425 · 24.04.2026 г., 16:27

Ubuntu 26.04 LTS 释出 2026-04-24 13:56 by 艾米七号 Canonical 释出了代号为 Resolute Raccoon 的 Ubuntu 26.04 LTS。同时释出的还有衍生版本 Edubuntu、Kubuntu、Lubuntu、Ubuntu Budgie、Ubuntu Cinnamon、Ubuntu Kylin、Ubuntu Studio、Ubuntu Unity 和 Xubuntu。Ubuntu Desktop、Ubuntu Server、Ubuntu Cloud、Ubuntu WSL 和 Ubuntu Core 将获得五年的支持,其余版本获得三年的支持,付费扩展支持 ESM (Expanded Security Maintenance)为十年 。Ubuntu 26.04 采用最新的 Linux 7.0 kernel,GNOME 50 桌面环境,引入了基于 TPM 的全盘加密,GStreamer 1.28,沙盒图形加载,Chrony 4.8,等等。 https://discourse.ubuntu.com/t/ubuntu-26-04-resolute-raccoon-lts-released/80833 #Ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18800 · 15.05.2026 г., 03:01

📰 Ubuntu 25.10 Users Can Now Upgrade to Ubuntu 26.04 LTS, Here’s How A step-by-step and easy-to-follow tutorial (with screenshots) on how to upgrade your Ubuntu 25.10 (Questing Quokka) installations to Ubuntu 26.04 LTS (Resolute Raccoon). 🔗 Source: https://9to5linux.com/ubuntu-25-10-users-can-now-upgrade-to-ubuntu-26-04-lts-heres-how #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18708 · 08.05.2026 г., 08:16

📰 Ubuntu Snap Prompting Improvements If you haven’t tried Ubuntu’s ‘Permission Prompting’ feature for a while, there’s more reason to do so in the latest release. Canonical’s Oliver Calder has shared an update on recent improvements to the security feature, which sets out to “empower users” by letting them decide what software can access on the rest of the system at runtime rather than retrospectively. 🔗 Source: https://www.omgubuntu.co.uk/2026/05/ubuntu-snap-prompting-client-improved #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18703 · 07.05.2026 г., 17:55

📰 Ubuntu Touch 24.04-1.3 Lands as UBports Prepares 24.04-2.0 UBports releases Ubuntu Touch 24.04-1.3 while preparing 24.04-2.0, targeting a newer Morph Browser stack with Qt 6 work. 🔗 Source: https://linuxiac.com/ubuntu-touch-24-04-1-3-released/ #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18696 · 07.05.2026 г., 08:38

📰After Days of DDoS, Now Ubuntu's Twitter Account Seems to be Compromised A fake AI agent, a near-identical Ubuntu URL, and a crypto wallet prompt, here's how hackers used Ubuntu's own branding against its users. 🔗 Source: https://feed.itsfoss.com/link/24361/17335930/ubuntu-twitter-compromised #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18694 · 07.05.2026 г., 06:14

📰 Ubuntu’s old Unity desktop remade in Wayfire and Libadwaita If Canonical hadn’t burned through cash and goodwill during its smartphone detour in the mid-2010s, Ubuntu would likely still ship with the Unity desktop today – albeit in an evolved form. What would that form actually look like? Well, you don’t have to shut your eyes and imagine, thanks to Ubuntu community member Muqtxdir, who’s experiment in “re-building ubuntu’s unity shell in a wayfire session through gtk4-layer-shell and libadwaita... 🔗 Source: https://www.omgubuntu.co.uk/2026/05/ubuntu-unity-desktop-wayfire-recreation #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18644 · 01.05.2026 г., 14:01

📰 Major DDoS attack knocks Ubuntu websites, Snap store offline If you’re having trouble accessing the Ubuntu website, the Snap store or Launchpad then you’re not alone: Canonical’s websites are currently facing a “sustained, cross-border” DDoS attack. The company says it is “working to address” the attack and will provide more details shortly. Some websites and services have been affected for as long as 14 hours (at the time of writing). 🔗 Source: https://www.omgubuntu.co.uk/2026/05/ubuntu-websites-ddos-attack #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18620 · 29.04.2026 г., 22:51

📰 Enabling Ubuntu Pro in Security Center is super easy Ubuntu 26.04 LTS dropped the Software & Updates utility from default installs and added Ubuntu Pro settings to the Security Center app. But is the setup experience any better? The short answer is yes, mostly. The range of options mirrors what was in the old Software & Updates > Ubuntu Pro tab, but the layout is less cramped, with more room for concise explanations of what each setting and toggle does. Enrolling is improved too. 🔗 Source: https://www.omgubuntu.co.uk/2026/04/enable-ubuntu-pro-security-center #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18586 · 27.04.2026 г., 13:07

📰 Ubuntu 16.04 LTS (Xenial Xerus) Reaches End of Standard ESM Support With the end of standard ESM support for Ubuntu 16.04 LTS, users must now choose between a staged upgrade or extended paid security coverage. 🔗 Source: https://linuxiac.com/ubuntu-16-04-lts-reaches-end-of-standard-esm-support/ #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18553 · 24.04.2026 г., 07:28

📰 5 Reasons to Upgrade to Ubuntu 26.04 (and 3 Reasons to Stay Away) Should you skip this new release or jump on the bandwagon and upgrade to 26.04? Let me help you with that. 🔗 Source: https://feed.itsfoss.com/link/24361/17324480/ubuntu-26-04-upgrade-or-not #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18526 · 22.04.2026 г., 10:54

📰 Ghostty OpenGL-Accelerated Terminal Available On Ubuntu 26.04 LTS Since Ubuntu 25.04 Ptyxis has been the default terminal emulator after it initially became available in Ubuntu 24.10. For the upcoming Ubuntu 26.04 LTS release, Ptyxis remains the default but Ghostty is now available too... 🔗 Source: https://www.phoronix.com/news/Ghostty-Ubuntu-26.04 #ubuntu

Hashtags

Linuxgram 🐧

@linuxgram · Post #18516 · 21.04.2026 г., 18:20

📰 Ubuntu 26.04 LTS: What’s new since 24.04? If you plan to upgrade to Ubuntu 26.04 LTS ‘Resolute Raccoon’ from Ubuntu 24.04 LTS, you’re going to inherit two years worth of improvements. As an LTS-to-LTS jump, you don’t simply benefit from what’s new in Ubuntu 26.04, but everything else added in the 3 interim releases prior, namely Ubuntu 24.10, 25.04 and 25.10. Ubuntu 26.04 LTS does plenty of things that 24. 🔗 Source: https://www.omgubuntu.co.uk/2026/04/ubuntu-26-04-lts-changes-since-24-04 #ubuntu

Hashtags

123•••910
ПретходнаСтраница 1 од 10Следна