一、isdigit()
python关于 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.isdigit()返回的是布尔值:True False
S中至少有一个字符且如果S中的所有字符都是数字,那么返回结果就是True;否则,就返回False
S1 = '12345' #纯数字
S2 = '①②' #带圈的数字
S3 = '汉字' #汉字
S4 = '%#¥' #特殊符号
print(S1.isdigit())print(S2.isdigit())print(S3.isdigit())print(S4.isdigit())#执行结果:
True
True
False
False
二、isalpha()
python关于 isalpha() 内置函数的官方定义:
S.isalpha() -> bool
Return True if all characters in S are alphabetic
and there is at least one character in S, False otherwise.
翻译:
S.isalpha()返回的是布尔值:True False</