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

Резултати

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

Пребарај: #psychology

当前筛选 #psychology清除筛选
Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40038 · 08.11.2025 г., 09:48

In what is known as the Dunning-Kruger effect, people who have low skill or knowledge in a certain area tend to overestimate their abilities, while those who are more highly skilled tend to underestimate their abilities. This happens because the metacognitive skills required to accurately assess one's own performance are also the skills necessary to perform well in the first place. @googlefactss#psychology

Hashtags

Journey to Fluency

@fluencyinenglish · Post #6846 · 10.02.2019 г., 05:07

Амин Махдави: #psychology @ieltsstrategies ❇️LIFE A young new mother hurriedly dropped off her toddler at daycare, only able to speak for a short minute before she ran off to catch the train. On that ill-fated day, the train crashed. Struggling for life, a bystander comforted her. “Think about your family,” she said. “About your children& your friends. You are loved.” She did her best to hold on, but the pain was too much. She was gone. While this story made headlines when a New Jersey commuter train crashed into a platform, it’s but one of many other perilous sagas where life is cut too short & our friends or loved ones are taken away due to illnesses, violence, accidents and natural disasters, just to name a few. The point? Life is so precious that rather than allowing the sands of time to slip through our hands, we have to seize the moment. Yet, we have difficulties with enjoying what we have in the present. We often find ourselves longing for something else, never really savoring what we have right now, in this very moment. Often, it takes some calamity or major strife for us to realize the fragility of life, & just how precious we all are in the eyes of someone near and dear to our hearts. It shouldn’t take massive amounts of pain to open our eyes to the beauty of what we have. We tend to allow the miracles that are happening all around us to fall by the wayside as we sit in wallow, immersed in fear, replete with stress & anxiety. It shouldn’t work like that. But we all know that it does. We all take this precious life for granted at one point or another in our lives. Yes, all of us. @ieltsstrategies However, if you’ve landed here, then there’s a reason why you’re reading these words. The simple fact will always remain that no matter what happens— no matter what trials or tribulations you've to dredge through, life will always be precious. We just have to find the good in every moment, no matter how meek or meager it might seem to us, because everything in life is subjective, gleaned upon by the status quo in our minds. @ieltsstrategies The problem with that? We don’t look to what we have. Rather, we’re deluged with a flood of thoughts immersed in what we don’t have. We envy others for enjoying success & the fruits of their labors while we live in a tormented state of pity & regret. It bothers us when people around us succeed. It bothers us that our seemingly small problems seem so big. Today, right now, at this very moment, there are people enduring a tremendous amount of strife. Not just afar in places like Syria or North Korea, but in our very own backyards. When you stop to think about it for a moment, there is an enormous amount of pain and suffering happening everywhere. The sheer enormity of it all can certainly feel overwhelming. However, the plight of others should remind us about the importance of the simple beauties and treasures in our own lives. Instead of looking to the haves, we must look to the have-nots as a reminder of what we do have rather than what we don’t have. We have to get off the Hedonic Treadmill & become more attuned to the preciousness in every moment of time. @ieltsstrategies The fact of the matter remains that we’re here one moment then gone the next. If we spend that infinitesimal amount of time steeped in worry & negative emotions, we’ll never realize the miraculous gift of life that we’ve been given. If you stop to think about the probability of life & our own existence, you’ll realize why every moment needs to be savored & treated like it could be our last. However, all of this is just talk. To the person who’s suffering through the torment of failure or has entirely lost hope in life, these are just words. The words might invoke some emotions, but they’re ultimately overpowered by the burden of thousands of pounds of problems resting like the weight of the world on our shoulders. Yet, no matter what the present situation might be— no matter how many problems might exist — this too shall pass & your faith must remain unwavering. @ieltsstrategies

Hashtags

Quiet World 🍁

@QuietWorld · Post #6447 · 08.05.2019 г., 15:30

Sleep deprivation has the opposite effect on healthy people versus those with depression. If you're healthy and sleep deprived, it can decrease your mood; however, it can improve the mood and cognitive abilities of people with depression. @googlefactss#psychology

Hashtags

Love & Relationship Tips ❤ 💖

@loveandrelationshiptips · Post #874 · 06.03.2023 г., 12:47

Look into someone’s eyes when you get a dissatisfactory answer. Sometimes we don’t like the answer to a question that we receive and sometimes we don’t understand it. Instead of repeating the question or asking another, look into the eyes of the person. This will make the person feel under pressure or cornered, and this will force them to further elaborate their thoughts. #psychology

Hashtags

Love & Relationship Tips ❤ 💖

@loveandrelationshiptips · Post #859 · 24.02.2023 г., 17:57

🦶 Look at someone’s feet before starting a conversation. Is there anything more awkward than starting a conversation with someone who clearly does not want to be talking to you? Fortunately, people tell a whole lot with their body language, including whether or not they’re open to having a conversation. Next time you see the opportunity to strike up a chat, take a quick glance at the other person’s feet. If the other person has turned only their body — not their feet — in your direction, psychology says they are not interesting in talking in that particular moment. #Psychology

Hashtags

Love & Relationship Tips ❤ 💖

@loveandrelationshiptips · Post #858 · 24.02.2023 г., 17:56

🗣 Use people’s first name to form a positive new relationship. When you meet someone new, start right away by referring to them by their first name. Studies have shown that people appreciate when people they’ve just met take the time to learn and remember their name. Taking the time to learn and use the name of a new friend will go a long way in establishing trust and friendship. #Psychology

Hashtags

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