@perspectiveix · Post #1465 · 13.08.2018 г., 18:00
🧠 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2KK6r5L 🚀@PerspectiveIX
Hashtags
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
Пребарај: #bigthought
@perspectiveix · Post #1465 · 13.08.2018 г., 18:00
🧠 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2KK6r5L 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1457 · 10.08.2018 г., 20:30
🧠 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2KHJq3t 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1453 · 09.08.2018 г., 20:30
🧠 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2KGAECw 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1449 · 08.08.2018 г., 20:30
📰 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2KD25xd 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1445 · 07.08.2018 г., 20:30
📰 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2OfFTLW 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1442 · 06.08.2018 г., 20:30
📰 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2KrRzsB 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1437 · 03.08.2018 г., 10:00
📰 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2LPiR1E 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1435 · 02.08.2018 г., 11:00
📰 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2Azz063 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1434 · 01.08.2018 г., 10:03
📰 Today's #BigThought by Martin Bryant: https://prs.pctvix.co/2OAHJYr 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1492 · 22.08.2018 г., 12:00
📰#iXDailyBrief STAT ⚡️ Research involving 109,780 internet users, aged 16-64 in 42 countries, shows that 46% use social media to stay abreast of current affairs. Out of this group, 29% are people aged 24-35, while 22% are 35-44. (Source: GWI) INSIGHT 🧠 Today #BigThought by Martin Bryant: https://prs.pctvix.co/2MJN5Te OTHER NEWS 📸 Instagram is testing Recommended Posts in the feed: https://prs.pctvix.co/2MLexzW 💸 Netflix is testing a payment feature to bypass Apple’s App Store fees: https://t.me/iXNews/31885 🗣 Snapchat Users Can Activate Face Effects Using Voice Commands: https://prs.pctvix.co/2MPpYa9 🤔 There should be ‘consequences’ for platforms that don’t remove people like Alex Jones, Senator Ron Wyden says: https://t.me/iXNews/31929 ⚖️ Facebook is rating the trustworthiness of its users on a scale from zero to one: https://prs.pctvix.co/2MJnv0N 🎮 Excitement brewing: Snap about to launch a game platform for Snapchat: https://prs.pctvix.co/2MGAmRb — 💌https://prs.pctvix.co/2wj5dt3 Ben, @iXNews 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1488 · 21.08.2018 г., 12:00
📰#iXDailyBrief STAT ⚡️ People Spent 85 Billion Hours In WhatsApp In The Past 3 Months (Versus 31 Billion In Facebook). 85 billion hours is a lot of time. It's 3.5 billion days, or over nine million years -- 9,582,650 years, to be exact. And it's 11.425 hours for every human being on the planet. (Source: Apptopia) INSIGHT 🧠 Today #BigThought by Martin Bryant: https://prs.pctvix.co/2woglF9 OTHER NEWS 🏛 Why Facebook needs a Supreme Court for content moderation: https://t.me/iXNews/31828 📺 Lifestyle publisher Stylist quits IGTV in favor of Apple News: https://t.me/iXNews/31818 🍕 Google created a fake pizza brand to test out creative strategies for YouTube ads: https://t.me/iXNews/31811 🎮 Amazon is ending its 20 percent Prime discount on video game preorders: https://t.me/iXNews/31803 🇻🇪 Venezuela ties its currency to a state-run cryptocoin: https://t.me/iXNews/31799 🚗 Tesla challenger Lucid Motors also in talks with Saudi Arabia for reported $1 billion funding: https://t.me/iXNews/31788 — Have you heard about Pulse? Check it out: https://prs.pctvix.co/2wj5dt3 Ben, @iXNews 🚀@PerspectiveIX
Hashtags
@perspectiveix · Post #1485 · 20.08.2018 г., 10:37
📰#iXDailyBrief STAT ⚡️ New research suggests that six second linear television ads can generate good levels of engagement. In this research, despite six second ads accounting for just 3%, they actually drove 6% of attention. Interestingly, six second ads generated more attention per second than 15 or 30 second ads. They also yielded higher attention per second among all age groups, with adults aged 35 and over paying slightly better attention to six second ads than younger consumers. (Source: Advertising Research Foundation (ARF)) INSIGHT 🧠 Today #BigThought by Martin Bryant: https://prs.pctvix.co/2Mym4Cj OTHER NEWS ⏯ Netflix sets the record straight over plans to introduce ads: https://prs.pctvix.co/2MIgQ6O 🎰 Apple cracks down on gambling apps in China: https://t.me/iXNews/31756 🐦 Jack Dorsey admits Twitter hasn’t ‘figured out’ approach to fake news: https://t.me/iXNews/31739 🗣 A university is outfitting living spaces with thousands of Echo Dots: https://t.me/iXNews/31735 👨👩👦👦 LinkedIn set to launch redesigned Groups platform by end of August: https://prs.pctvix.co/2nTpxgK — "Success is to wake up each morning and consciously decide that today will be the best day of your life." ― Ken Poirot Happy Monday! Ben, @iXNews 🚀@PerspectiveIX
Hashtags