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

Резултати

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

Пребарај: #karagarga

当前筛选 #karagarga清除筛选
PT资讯频道

@PrivateTrackerNews · Post #773 · 03.08.2019 г., 16:27

#Karagarga (KG) Donations (2019) We have now collected all the funds required. Donations are closed again until 2020. Thank you for your contributions. We've also handed out all donor stars. If we missed you through administrative oversight, please contact ***. 捐款(2019年) 我們現在收集了所需的所有資金。 捐款將再次關閉,直到2020年。 感謝您的貢獻。 我們還發放了所有捐贈明星。 如果我們通過行政監督錯過了您,請聯繫***。

Hashtags

PT风向旗

@Ptfxq · Post #375 · 14.10.2022 г., 22:00

#karagarga#KG The Pot The pot system has been functioning well for more than a decade now, big thanks to all subtitlers and pledgers. Please check if you have claimed any pots. Go to your profile, and after Pot Pledges click on (claimed pots). If you are working on a pot, leave a comment there about progress, and update that post at least every 3 months. If not, cancel your claim. A dormant claim can discourage a potential subtitler. Also, please keep an eye from time to time on pots you started or pledged to (see Pot Pledges in your profile). If good subtitles appeared in the meantime, report that pot with a link to the subs. If you want to subtitle a film for which the pot has been claimed long ago without any news, please contact one of us (corvusalbus, flipflink, cyzs, musiclova). Happy subtitling and viewing!

PT风向旗

@Ptfxq · Post #279 · 28.07.2022 г., 23:35

#KaraGarga#KG#开放捐赠 2022-07-26 Annual Donations (2022) Dear all, we've to collect donations for server / hosting expenses for the year ahead. Please contact stefflbw by pm if you can contribute this year. If you have donated in 2020 or 2021 you can follow the same link / method. In that case please PM stefflbw (with the transaction details) when the donation is complete. If you do not wish to have a donor star activated beside your profile name, please let us know. "What is a suitable amount?" is a frequently asked question. Donations between $10 and $50 have been the most typical. Occasionally members have donated substantially more but the bulk of the annual bill is generally financed by a high number of "smaller" donations. We will post regular updates on the donations total percentage below. Thank you, the KG jungle gym team

PT风向旗

@Ptfxq · Post #926 · 16.08.2025 г., 16:00

#KaraGarga#KG#开放捐赠#慢讯#群友投稿 只是年度捐赠,没有捐入 Dear all, we are commencing our annual donations drive. The funds collected will cover server / hosting expenses from September 2025 to September 2026. How much might a member donate? A typical donation amount in previous years was $10 to $50. A few members have donated substantially more but the bulk of our funds is collected through a higher volume of typical donations. If you have the opportunity to donate in 2025, please PM () for instructions. (If you have donated previously, the instructions have not changed) Much love from The Crow Sanctuary boffins. Target percentage: Aug 3: 17% Aug 4: 28% Aug 5: 37% Aug 6: 47% Aug 7: 56% Aug 8: 69% Aug 9: 74% Aug 10: 77% Aug 11: 80% Aug 12: 85% Aug 14: 87% Aug 15: 90%