Determining whether a digital string
a='123'
if a.isdigit():
print("a是数字" )
else:
print("a不是数字")
The results are:
whether the string is a letter
a='abc'
print( "是否是字母:%s"%(a.isalpha()) )
b=' '
print( "是否是空格:%s"%(b.isspace()) )
function | Explanation |
---|---|
isdigit | digital |
Islf | letter |
isspace | Blank |
isdecimal | Decimal |
islower | Lower case letters |
isupper | uppercase letter |
istitl to | Word capitalized |
isalnum | Letters and numbers |