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 слични објави

Пребарај: #32pages

当前筛选 #32pages清除筛选
PT资讯频道

@PrivateTrackerNews · Post #771 · 02.08.2019 г., 14:49

2019/08/02 #开放注册 #OpenSignupTracker #国内PT 整理自电报 @PT资讯频道 Telegram @privatetrackernews 经典/老电影 Tracker's Name: #ILoveClassics (ILC) Genre: Movies Sign-up Link: http://www.iloveclassics.com/signup.php Closing date: N/A Additional information: I Love Classics (ILC) is a Private Torrent Tracker dedicated mostly to older and unique content. 综合站 Tracker's Name: #Demonoid Genre: General Sign-up Link: https://www.dnoid.to/register.php Closing date: Additional information: Demonoid is a Private Torrent Tracker for General. 新站综合站 Tracker Name: #TazmaniaDen Genre: General Sign Up Link: https://tazmania-den.net/account-signup.php Closing Time: ? Additional Information: New tracker for General. 音频软件/样片 Tracker's Name: #AudioNews (AN) Genre: Other Sign-up Link: https://audionews.org/profile.php?mode=register Closing date: 24h Additional information: AudioNews (AN) is a Private Torrent Tracker for Audio Software / Samples / ETC. 综合站 Tracker Name: #4thDimension Genre: General Signup Link: https://4thd.xyz Closing Date: 3rd August 2019 Additional comments: Annual rare opening 24 hour sign up. small exclusive site no bots, selected quality fast content TV dominant. most cats but no games. Gazelle based site with active forum shout comps. Join us in the 4th Dimension #OpenApplicationSignupTracker #开放申请注册 漫画 Tracker's Name: #32Pages (Open for Application Signup) Genre: Other Sign-up Link: https://32pag.es/application.php Closing date: N/A Additional information: 32Pages is a Private Torrent Tracker for Comic Books.

PT资讯频道

@PrivateTrackerNews · Post #558 · 01.06.2019 г., 05:18

2019/06/01 #开放注册 #OpenSignupTracker #国外PT 整理自电报@PT资讯频道 @privatetrackernews 设计素材类 Tracker's Name: #CGPeers Genre: Other Sign-up Link: https://www.cgpeers.to/register.php Closing date: Open for about 48 hours. Additional information: CGPeers is a Private Torrent Tracker for 3D/Visual Effects / Computer Graphics/Design / Computer Assisted Art material. 电影电视综合站 Tracker's Name: #Twilights Genre: General Sign-up Link: https://twilightsdreams.com/signup.php Closing date: Open for a week. Additional information: Twilights is a Private Torrent Tracker for Movies / TV / General Releases. 音乐站 Tracker's Name: #MusicBox Genre:Music Sign-up Link: https://musicbox.si/?p=signup&pid=16 Closing date: Not In The Near Future Additional information: This is an english torrent site for MP3 music from all genres. 电视电影音乐综合站 Tracker's Name: #CrazyBitchTV Genre:General Sign-up Link: http://cbtv.info/signup.php? Closing date: Not In The Near Future Additional information:CBTV is a brand new general tracker offering the greatest and letest in tv movies and music. They have a great staff and a dj team with an active shout and forums. You maybe surprised to know like i was that the site belongs to Mazy. Do come and have a look for yourselves. Those who signup and come into shout and say hail mazy get 5GB upload and 500BP 印度电影电视综合站 Tracker's Name: #BwTorrents Genre:General Sign-up Link: https://bwtorrents.tv/signup.php Closing date: N/A Additional information: BwTorrents is an Indian Private Torrent Tracker for Movies / TV / General Releases. 综合站 Tracker's Name: #xbladeskingdom Genre:General Sign-up Link: https://xblades-kingdom.net/signup.php Closing date: no closeing date Additional information:We are back on line seedbox torrents we are looking for uploaders and staff mods #开放申请注册 #OpenApplicationSignupTracker 漫画 Tracker's Name: #32Pages (Open for Application Signup) Genre:Other Sign-up Link: https://32pag.es/application.php Closing date: Open for a few days Additional information:32Pages (ComicBT) is a Private Torrent Tracker for Comic Books. 苹果电脑软件 Tracker's Name: #MacTorrents (Open for Application Signup) Genre: Other Sign-up Link: https://mac-torrents.me/register.php Additional information: Mac Torrents is a Private Torrent Tracker for Mac Software Releases. 德国综合站 Tracker's Name: #BiTTiTAN (Open for Application Signup) Genre:General Sign-up Link: https://bit-titan.net/invite_ask.php Closing date: N/A Additional information:BiT-TiTAN is a German Private Torrent Tracker for General Content