2019-05-24
----------------------------
# isalpha() 检测字符串是否是字母组成 返回布尔值
s = ‘I 狗like dog‘
s1 = ‘I狗likedog‘
print(s.isalpha())
print(s1.isalpha())
---------------------------
# isalnum() 检测字符串是否有字母加数字组成 返回布尔值
s = ‘I 狗li414ke dog‘
s1 = ‘I狗likedog132132‘
s2 = ‘3133‘
print(s.isalnum())
print(s1.isalnum())
print(s2.isalnum())
----------------------------
# isdigit() 检测字符串是否由整数组成
# isdecimal()
# isnumeric()
s = ‘123‘
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
print(‘=‘*20)
s = b‘101100‘
print(s.isdigit())
#print(s.isdecimal())
#print(s.isnumeric())
print(‘=‘*20)
-----------------------------
原文地址:https://www.cnblogs.com/niaocaizhou/p/10917193.html
时间: 2024-10-13 09:42:31