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

Резултати

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

Пребарај: #pamelaquibec

当前筛选 #pamelaquibec清除筛选
repoRTeros

@RTReporteros · Post #8791 · 20.03.2026 г., 22:45

Hoy en el Club de Periodistas reconocieron también el reportaje titulado: ‘Perros de búsqueda y rescate’. Debo contarles una anécdota. Cuando Alberto y yo salimos rumbo a la zona del desastre (por el huracán categoría 5 que azotó Acapulco) en carretera éramos el, yo, la oscuridad... hasta que una camioneta comenzó a perseguirnos. En el absoluto y el más terrorífico silencio estuvimos varios kilómetros avanzando... Hasta que decidieron dejarnos ir. Estoy segura que alguien nos cuidó esa noche. Este reportaje más que una investigación, fue un profundo homenaje a los perros rescatistas mexicanos y sus humanos, que se entrenan para salvar vidas. Si no lo han visto, por favor, no se lo pierdan. Les dejo muchísimo cariño y agradecimiento por acompañarnos desde el otro lado del cristal. 🐶🔗https://sn-esp.site/Jh6d 🧑‍💻#PamelaQuibec🌷 Día a día con🎤@RTReporteros 🐦 (X) Twitter

repoRTeros

@RTReporteros · Post #7864 · 28.10.2025 г., 22:15

🌷La flor de cempasuchitl es la gran protagonista de las ofendas mexicanas. ¿Sabías que tiene una hermosa leyenda? ¡Te la cuento! Besos mágicos 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #7747 · 27.09.2025 г., 01:53

¿Les pasa que su celular o las redes sociales les recuerdan cosas? Hoy, justo, me aparecieron estas fotos de una fecha muy valiosa para mí: 26 de septiembre de 2018. En ese entonces, recibí una llamada desde Moscú para avisarme que estaba dentro de RT. En ella, me dieron algunos detalles de cuándo sería mi ingreso oficial a la corresponsalía mexicana (¡la que sí cuenta como fecha de aniversario!). La llamada llegó mientras decidía qué comer ese día... ¡Y vaya que lo supe! A veces, los recuerdos que dejas plasmados regresan a contarte historias sobre ti. Seguimos 💚 🧑‍💻#PamelaQuibec🌷 Día a día con🎤@RTReporteros 🐦 (X) Twitter

repoRTeros

@RTReporteros · Post #7604 · 20.08.2025 г., 23:34

¡Juego! 🎲 ¿A dónde creen que voy con equipo desde Moscú? En el video, una pista. 🕵️‍♀️🔎 ¡Besos! 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #7573 · 07.08.2025 г., 16:34

¡Los mexicanos comemos cactus! 🌵 Sí, en nuestra muy variada y deliciosa gastronomía tenemos muchos platillos que pueden parecer exóticos. Aquí los conocemos como nopales y acompañan muchos guisos, aunque también se comen solitos, asados con limón, sal y salsita. Además, hoy son creaciones artísticas. Se las dejo. ¡Besos sin espinas! 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #6853 · 13.02.2025 г., 02:39

¿Me acompañan en una cita el 14 de febrero en la señal de RT? Vamos a tener al aire uno de los reportas donde nos vamos a topar con ese... El amor incondicional 🐾 Hasta entonces... ¡Besos! ¡Y deséenme suerte para ganar! 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #6756 · 20.01.2025 г., 14:18

¿Adivinaron? Gracias por jugar conmigo... ¡Y les voy contando! Besos porteños 🩵 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #6747 · 18.01.2025 г., 15:23

Hoy tengo un juego de adivinanza para ustedes, ¿juegan? 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #6744 · 17.01.2025 г., 00:00

Ir al teatro a ver una puesta en escena es una de las cosas más gratificantes del mundo. 🎭 Yo, que he tenido la oportunidad de estar en una obra musical, les puedo decir el enorme esfuerzo que supone que logre representarse. Para que todo eso suceda se necesita una mente creativa, loca, apasionada que diriga el sueño... Porque sí, el teatro es eso, un sueño que ocurre en un escenario. No se pierdan la entrevista hoy, en la señal de RT. 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #6729 · 11.01.2025 г., 08:30

La locación de este día es un lugar con muchísimo significado para las personas fieles a la religión católica, pero también un punto turístico por excelencia en esta nación. No les cuento más. Un beso 😘 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #6648 · 20.12.2024 г., 16:37

Verbenas navideñas Acá en México, estamos ya en las posadas y eso da pie a verbenas populares para disfrutar, comer y comprar. ¡Les enseño! Un beso, 🧑‍💻#PamelaQuibec🌷 Día a día con 🎤@RTReporteros 🐦(X)Twitter

repoRTeros

@RTReporteros · Post #6844 · 10.02.2025 г., 17:23

En el fútbol ⚽️ ¡nada como las revanchas! Y luego de la estadía en La Boca, hubo una segunda visita "obligada" ¡Aquí lo tienen! 🧑‍💻#PamelaQuibec🌷 🧑‍💻#RicardoRomero Día a día con 🎤@RTReporteros 🐦(X)Twitter

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