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

Резултати

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

Пребарај: #launch

当前筛选 #launch清除筛选
SpaceX

@SpaceX · Post #10307 · 14.02.2024 г., 18:58

🚀Next launchStarlinkGroup7-14 RocketFalcon9Block5 FromSLC-4E,VandenbergSFB🇺🇸 🕙Launch time February 15th, 01:34 UTC🆕 🌍Mission information TypeCommunications OrbitLowEarthOrbit 🚀Vehicle information CoreB1082.2(2ndflight♻️) LandingOCISLY(ASDS🌊) ℹ️ A batch of 22 satellites for the Starlink mega-constellation - SpaceX's project for space-based Internet communication system. #Launch

Hashtags

SpaceX

@SpaceX · Post #10306 · 14.02.2024 г., 18:33

🚀Next launchUSSF-124 RocketFalcon9Block5 FromSLC-40,CapeCanaveral🇺🇸 🕙Launch time February14th,22:30UTC 🌍Mission information TypeGovernment/TopSecret OrbitLowEarthOrbit 🚀Vehicle information CoreB1078.7(7thflight♻️) LandingLZ-2(RTLS) ℹ️ 2 satellites, one by L3Harris and the other by Northrop Grumman, will be launched as the Hypersonic and Ballistic Tracking Space Sensor (HBTSS) mission for the US Missile Defense Agency. These satellites have improved sensitivity to detect and track hypersonic missiles with fainter signatures. #Launch

Hashtags

SpaceX

@SpaceX · Post #10290 · 12.02.2024 г., 23:47

🚀Next launchNova-CIM-1 RocketFalcon9Block5 FromLC-39A,KennedySpaceCenter🇺🇸 🕙Launch time February15th,06:05 UTC 🆕 🌍Mission information TypeLunarExploration OrbitLunarOrbit 🚀Vehicle information CoreB1060.18(18thflight♻️) LandingLZ-1(RTLS) ℹ️ This is the first flight of Nova-C lander which was developed by Intuitive Machines. This mission is a part of CLPS program and carries various NASA payloads in support of Artemis lunar program, as well as multiple commercial payloads. #Launch

Hashtags

SpaceX

@SpaceX · Post #10130 · 29.12.2023 г., 01:38

🚀Next launchStarlinkGroup6-36 RocketFalcon9Block5 FromSLC-40,CapeCanaveral🇺🇸 🕙Launch time December29th,04:01UTC 🌍Mission information TypeCommunications OrbitLowEarthOrbit 🚀Vehicle information CoreB1069.12 (12thflight♻️) LandingASOG(ASDS🌊) ℹ️ A batch of satellites for the Starlink mega-constellation. #Launch

Hashtags

SpaceX

@SpaceX · Post #10119 · 27.12.2023 г., 14:34

🚀Next launchOTV-7(X-37B)(USSF-52) RocketFalconHeavy FromLC-39A,KennedySpaceCenter🇺🇸 🕙Launch time December29th,01:07UTC 🌍Mission information TypeGovernment/TopSecret OrbitUnknown 🚀Vehicle information CoreB1084.1(1stflight🌟) ExpendableLastflight🌠 Boosters B1064.5(♻️x4) (RTLS: LZ-1) B1065.5(♻️x4) (RTLS: LZ-2) ℹ️ It is the seventh flight of the 📷X-37B program. United States Air Force Orbital Test Vehicle is built by Boeing. #Launch

Hashtags

SpaceX

@SpaceX · Post #10075 · 23.12.2023 г., 11:34

🚀Next launchSARah2&3 RocketFalcon9Block5 FromSLC-4E,VandenbergSFB🇺🇸 🕙Launch time December24th, 13:11UTC🆕 🌍Mission information TypeGovernment/TopSecret OrbitPolarOrbit 🚀Vehicle information CoreB1075.8 (8thflight♻️) LandingLZ-4(RTLS) ℹ️ SARah 2 & 3 are two passive reflector antenna radar satellites built by OHB-System, based on the reflector-antenna technology of SAR-Lupe. They are part of the three satellite constellation being built for the German government as a follow-up to the SAR-Lupe radar sat constellation. #Launch

Hashtags

SpaceX

@SpaceX · Post #10036 · 18.12.2023 г., 18:02

🚀Next launchStarlinkGroup6-34 RocketFalcon9Block5 FromSLC-40,CapeCanaveral🇺🇸 🕙Launch time December19th,04:01UTC 🆕 🌍Mission information TypeCommunications OrbitLowEarthOrbit 🚀Vehicle information CoreB1081.3(3rdflight♻️) LandingASOG(ASDS🌊) ℹ️ A batch of satellites for the Starlink mega-constellation. #Launch

Hashtags

SpaceX

@SpaceX · Post #10030 · 12.12.2023 г., 01:30

🚀Next launchStarlinkGroup6-34 RocketFalcon9Block5 FromSLC-40,CapeCanaveral🇺🇸 🕙Launch time December 13th, 04:05 UTC🆕 🌍Mission information TypeCommunications OrbitLowEarthOrbit 🚀Vehicle information CoreB1081.3(3rdflight♻️) LandingASOG(ASDS🌊) ℹ️ A batch of satellites for the Starlink mega-constellation #Launch

Hashtags

SpaceX

@SpaceX · Post #10023 · 10.12.2023 г., 00:02

🚀Upcoming launchOTV-7(X-37B)(USSF-52) RocketFalconHeavy FromLC-39A,KennedySpaceCenter🇺🇸 🕙Launch time December 13th, 01:14 UTC🆕 🌍Mission information TypeGovernment/TopSecret OrbitUnknown 🚀Vehicle information CoreB1084.1(1stflight🌟) ExpendableLastflight🌠 Boosters B1064.5(♻️x4) (RTLS: LZ-1) B1065.5(♻️x4) (RTLS: LZ-2) ℹ️ It is the seventh flight of the 📷X-37B program. United States Air Force Orbital Test Vehicle is built by Boeing. #Launch

Hashtags

SpaceX

@SpaceX · Post #10021 · 06.12.2023 г., 10:01

🚀Next launchStarlinkGroup6-33 RocketFalcon9Block5 FromSLC-40,CapeCanaveral🇺🇸 🕙Launch time December7th,04:01UTC 🌍Mission information TypeCommunications OrbitLowEarthOrbit 🚀Vehicle information CoreB1077.9(9thflight♻️) LandingJRTI(ASDS🌊) ℹ️ A batch of 23 satellites for the Starlink mega-constellation. #Launch

Hashtags

SpaceX

@SpaceX · Post #10011 · 02.12.2023 г., 20:30

🚀Next launchStarlinkGroup6-31 RocketFalcon9Block5 FromSLC-40,CapeCanaveral🇺🇸 🕙Launch time December3rd,04:00UTC 🌍Mission information TypeCommunications OrbitLowEarthOrbit 🚀Vehicle information CoreB1078.6(6thflight♻️) LandingASOG(ASDS🌊) ℹ️ A batch of satellites for the Starlink mega-constellation #Launch

Hashtags

SpaceX

@SpaceX · Post #9997 · 01.12.2023 г., 00:10

🚀Next launch425ProjectFlight1andothers RocketFalcon9Block5 FromSLC-4E,VandenbergSFB🇺🇸 🕙Launch time December1st,18:19 UTC 🆕 🌍Mission information TypeGovernment/TopSecret OrbitSun-SynchronousOrbit 🚀Vehicle information CoreB1061.17(17thflight♻) LandingLZ-4(RTLS) ℹ️ Note: Name of payload is provisional. First launch of an ultimately 5 reconnaissance satellites for the South Korean Defense Acquisition Program Administration (DAPA), with 1 satellite featuring an electro-optical infrared (EO/IR) telescope. #Launch

Hashtags

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