isdecimal(...) | S.isdecimal() -> bool | | Return True if there are only decimal characters in S, | False otherwise.
翻译:如果S中只有十进制字符,则返回True,否则为False。
isdigit(...) | S.isdigit() -> bool | | Return True if all characters in S are digits | and there is at least one character in S, False otherwise.
翻译:如果S中的所有字符都是数字,并且在S中至少有一个字符,则返回True。
isnumeric(...) | S.isnumeric() -> bool | | Return True if there are only numeric characters in S, | False otherwise.
翻译:如果S中只有数字字符,则返回True,否则为False。
1 s = '123' 2 print(s.isdigit()) 3 print(s.isdecimal()) 4 print(s.isnumeric())
结果为:
True True True
s = b'123' print(s.isdigit()) #print(s.isdecimal()) #print(s.isnumeric())
结果为: (只有第一个能正常输出,另外两个报属性错误)