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

Резултати

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

Пребарај: #urbanization

当前筛选 #urbanization清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #699 · 06.09.2025 г., 16:22

🌎 Land reclamation has transformed Singapore’s size by about 25% since 1819, expanding the island using sand and soil from neighboring countries. The ongoing Tuas Megaport project will create new coastline with over 221 million cubic meters of fill material. ✨ #geography⚡#engineering⚡#urbanization 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1397 · 12.05.2026 г., 22:11

🌎 Dubai’s Palm Jumeirah is an artificial archipelago built from over 120 million cubic meters of sand and rock. Constructed in the shape of a palm tree, it adds 56 kilometers of new coastline to the city. ✨ #engineering⚡#urbanization⚡#shoreline 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #646 · 24.02.2026 г., 20:31

🌍 The average human today is more likely to live in a city than in the countryside—over 56% of the world’s population is now urban, a dramatic shift from just a few generations ago. ✨ #population⚡#urbanization⚡#cities⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #13 · 09.08.2025 г., 16:27

🌍 Over half of the world’s population now lives in cities, a dramatic shift from 1950 when only about 30% lived in urban areas. Urbanization is rapidly transforming our planet. ✨ #population⚡#urbanization⚡#cities⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Amazing Geography 🌍

@amazingeo · Post #15 · 10.08.2025 г., 00:12

🌍 In 1800, fewer than 1 billion people lived on Earth. Today, the world population has soared past 8 billion, with more than half living in urban areas like cities and large towns. ✨ #population⚡#urbanization⚡#demographics⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Amazing Geography 🌍

@amazingeo · Post #225 · 12.09.2025 г., 20:12

🌍 In 2022, Nigeria’s largest city, Lagos, became one of only two megacities in Africa to surpass 20 million residents, helping drive Africa’s rapid urban population growth. ✨ #population⚡#urbanization⚡#Africa⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #137 · 29.08.2025 г., 09:12

🌍 Some cities, like Johannesburg, are built on high plateaus called "highveld," sitting over 1,700 meters above sea level. Their altitude shapes local climate and city life in unique ways. ✨ #urbanization⚡#elevation⚡#climate⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #211 · 10.09.2025 г., 13:12

🌍 By 2050, city dwellers are expected to make up nearly 70% of the global population. Urban areas are now growing twice as fast as rural regions, reshaping how billions of people live. ✨ #urbanization⚡#cities⚡#demographics⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Irina Kalabikhina

@kalabikhina · Post #1139 · 26.01.2026 г., 12:11

🆕10(1)/2026 🔗Исторические и современные предикторы региональных культурных различий в индивидуализме и коллективизме в России Андрей А. Григорьев, Альбина А. Галлямова, Дмитрий С. Григорьев, Джон У. Берри В данном исследовании, основанном на экокультурном подходе, изучаются исторические и современные факторы, предсказывающие региональные культурные различия в соотношении индивидуализма (далее – ИНД) и коллективизма (далее – КОЛ, а для соотношения: ИНД/КОЛ) в России, с акцентом на частную собственность на землю в конце XIX – начале XX века и современную занятость в сельском хозяйстве. Анализ показывает, что регионы с более высокой распространенностью частной собственности на землю в 1877 г. и 1905 г. демонстрируют более выраженные тенденции ИНД в современных региональных границах, что свидетельствует о преемственности культурных черт. Кроме того, современные факторы, такие как доля рабочей силы в сельском хозяйстве и этнический состав, в частности доля этнических русских, оказываются значимыми предикторами различий ИНД/КОЛ. Однако урбанизация не обнаруживает значимой связи с региональными культурными различиями в ИНД/КОЛ, что указывает на то, что, хотя она может быть связана с ИНД, она не является основным предиктором. Результаты подчеркивают, что факторы, коренящиеся в традиционных типах хозяйства, вызывают глубокие и долгосрочные последствия для региональных культурных различий, сохраняясь даже в условиях масштабных общественных преобразований, произошедших в советское время. ▫️Публикация в журнале осуществляется бесплатно благодаря поддержке «АКБ «Держава» ПАО» и Экономического факультета МГУ имени М.В.Ломоносова. #population_and_economics#regional_culture#individualism_collectivism#urbanization

Amazing Geography 🌍

@amazingeo · Post #84 · 20.08.2025 г., 16:12

🌍 The largest internal migration in history occurred in China, with over 200 million people moving from rural villages to booming cities since the 1980s, transforming the nation’s economy and society. ✨ #migration⚡#China⚡#urbanization⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Amazing Geography 🌍

@amazingeo · Post #83 · 20.08.2025 г., 13:12

🌍 Between 2010 and 2020, India saw more internal migrants than any other country, with tens of millions moving from villages to cities in search of work and better living conditions. ✨ #migration⚡#India⚡#urbanization⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Amazing Geography 🌍

@amazingeo · Post #251 · 17.09.2025 г., 03:12

🌍 In 2021, Luxembourg became the first country to offer free nationwide public transport. This move reshapes economic geography by making travel easier and connecting people to jobs and services. ✨ #transport⚡#economy⚡#urbanization⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

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