num = "1" #unicode
Num.isdigit () # True
Num.isdecimal () # True
Num.isnumeric () # True
num = "1" # Full width
Num.isdigit () # True
Num.isdecimal () # True
Num.isnumeric () # True
num = b "1" # byte
Num.isdigit () # True
Num.isdecimal () # attributeerror ' bytes ' object has no attribute ' isdecimal '
Num.isnumeric () # attributeerror ' bytes ' object has no attribute ' IsNumeric '
num = "IV" # Roman numerals
Num.isdigit () # True
Num.isdecimal () # False
Num.isnumeric () # True
num = "Four" # Kanji
Num.isdigit () # False
Num.isdecimal () # False
Num.isnumeric () # True
===================
isdigit ()
true:unicode number, byte digit (single byte), full-width digit (double byte), Roman numerals
False: Chinese numerals
Error: None
Isdecimal ()
true:unicode number, full-width digit (double-byte)
False: Roman numerals, Chinese numerals
error:byte number (single byte)
IsNumeric ()
true:unicode numbers, full-width numerals (double-byte), Roman numerals, Chinese numerals
False: None
error:byte number (single byte)
================
Import Unicodedata
Unicodedata.digit ("2") # 2
Unicodedata.decimal ("2") # 2
Unicodedata.numeric ("2") # 2.0
Unicodedata.digit ("2") # 2
Unicodedata.decimal ("2") # 2
Unicodedata.numeric ("2") # 2.0
Unicodedata.digit (b "3") # Typeerror:must is str, not bytes
Unicodedata.decimal (b "3") # Typeerror:must is str, not bytes
Unicodedata.numeric (b "3") # Typeerror:must is str, not bytes
Unicodedata.digit ("Ⅷ") # Valueerror:not a digit
Unicodedata.decimal ("Ⅷ") # Valueerror:not a decimal
Unicodedata.numeric ("Ⅷ") # 8.0
Unicodedata.digit ("four") # Valueerror:not a digit
Unicodedata.decimal ("four") # Valueerror:not a decimal
Unicodedata.numeric ("four") # 4.0
# "0", "0", "one", "Tearoom", "Two", "弐", "three", "ginseng", "four", "five", "six", "seven", "eight", "Nine", "Ten", "20", "30", "registered", "Hundred", "thousand", "million", "million", "Million"
The difference between Str function isdigit, isdecimal and IsNumeric in Python