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

Резултати

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

Пребарај: #gnome

当前筛选 #gnome清除筛选
Linuxgram 🐧

@linuxgram · Post #18481 · 18.04.2026 г., 13:42

📰GNOME's Maps, Graphs, RustConn & Other App Improvements For pairing nicely with the GNOME 50 desktop release last month, a number of GNOME-associated apps have been seeing new features and refinements... 🔗 Source: https://www.phoronix.com/news/GNOME-Graphs-2.0-Maps-Transit #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #18443 · 15.04.2026 г., 10:31

📰 GNOME 50.1 Released with Basic Zoom Support for the Captive Portal GNOME 50.1 is now available as the first point release to the GNOME 50 desktop environment series with various bug fixes and improvements across several core components and default apps. 🔗 Source: https://9to5linux.com/gnome-50-1-released-with-basic-zoom-support-for-the-captive-portal #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #18407 · 13.04.2026 г., 10:37

📰Quick Lofi – a GNOME extension for chill beats to study to Quick Lofi is a GNOME Shell extension that puts a lofi radio player in your top bar. If you’ve ever opened a new browser tab to load a “lofi beats to study to” stream on YouTube — lofi girl, perhaps – to act as an ambient backdrop to work to, the appeal will be evident. If not, all you need to know is that mellow, lyric-free, low-tempo sounds are reputedly ideal for focus. 🔗 Source: https://www.omgubuntu.co.uk/2026/04/quick-lofi-beats-gnome-extension #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #18391 · 11.04.2026 г., 14:30

📰 GNOME-Aligned Amberol 2026.1 Music Player Released, Phosh Improves X11 Support A few weeks past the GNOME 50 release and there continues to be a lot of ongoing GNOME app activity worth highlighting... 🔗 Source: https://www.phoronix.com/news/GNOME-Amberol-2026.1 #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #18361 · 09.04.2026 г., 07:49

📰Dynamic Music Pill brings lyrics to your GNOME desktop A clutch of new features are available in Dynamic Music Pill, the slick now playing and media controller extension for GNOME Shell. The “big” new addition is lyrics support. When you listen to a track with synced lyrics in a compatible player, you can view those lyrics by opening the applet controller and clicking on the album art inside of it: The lyrics are shown in a freely scrollable widget, with the active line bolder in white for more... 🔗 Source: https://www.omgubuntu.co.uk/2026/04/lyrics-feature-dynamic-music-pill-extension #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #18241 · 30.03.2026 г., 09:20

📰 GNOME 51 “A Coruña” Desktop Environment Scheduled for September 16th, 2026 The development cycle of the upcoming GNOME 51 “A Coruña” desktop environment kicks off with a draft release schedule suggesting the final release is expected later this year on September 16th, 2026. 🔗 Source: https://9to5linux.com/gnome-51-a-coruna-desktop-environment-scheduled-for-september-16th-2026 #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #18193 · 26.03.2026 г., 10:43

📰 Tails 7.6 Introduces Automatic Tor Bridges to Bypass Censorship Tails 7.6 adds built-in Tor bridge support for restricted networks and switches to GNOME Secrets as the default password manager. 🔗 Source: https://linuxiac.com/tails-7-6-introduces-automatic-tor-bridges-to-bypass-censorship/ #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #18123 · 20.03.2026 г., 14:41

📰GNOME 50 “Tokyo” Desktop Environment Officially Released, This Is What’s New GNOME 50 desktop environment is now available as a major release that introduces numerous new features and improvements. Here’s what’s new! 🔗 Source: https://9to5linux.com/gnome-50-tokyo-desktop-environment-officially-released-this-is-whats-new #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #17957 · 03.03.2026 г., 23:10

📰 Pop!_OS 22.04 LTS Users Can Now Officially Upgrade to Pop!_OS 24.04 LTS System76 begins the official upgrade rollout from Pop!_OS 22.04 LTS to 24.04 LTS, replacing GNOME with the new COSMIC desktop environment. 🔗 Source: https://linuxiac.com/pop_os-22-04-lts-users-can-now-officially-upgrade-to-pop_os-24-04-lts/ #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #17926 · 28.02.2026 г., 13:05

📰 GNOME GitLab Redirecting Some Git Traffic To GitHub For Reducing Costs If you are cloning from a GNOME repository on their GitLab and now finding your Git traffic being redirected to GitHub, you are not alone. GNOME's infrastructure team is now redirecting Git traffic from the GNOME.org GitLab over to GitHub mirrors for reducing bandwidth costs... 🔗 Source: https://www.phoronix.com/news/GNOME-GitHub-GitLab-Redirect #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #17895 · 25.02.2026 г., 21:01

📰 GTK 4.22 In Good Shape With Better SVG Support Matthias Clasen shared an update today concerning the state of Scalable Vector Graphics (SVG) within GNOME's GTK toolkit... 🔗 Source: https://www.phoronix.com/news/GTK-4.22-SVG-2026 #gnome

Hashtags

Linuxgram 🐧

@linuxgram · Post #17892 · 25.02.2026 г., 08:57

📰 Dynamic Music Pill puts slick media controls in your GNOME panel Dynamic Music Pill is a GNOME Shell extension that embeds a pill-shaped media controller into your desktop panel or dock. It shows album art, artist name and track title alongside an animated waveform visualiser. If that sounds unashamedly blingy, it’s because it is – nothing wrong in that, right? The extension received an update today, which seem a good hook to actually take this off my “to write about” list. 🔗 Source: https://www.omgubuntu.co.uk/2026/02/dynamic-music-pill-gnome-panel-media-controller #gnome

Hashtags

ПретходнаСтраница 1 од 5Следна