isalnum()判断是否包含字母或者数字
isalpha()判断是否都是字母
istitle()判断每个单词首字母是否是大写
isspace()判断是否是空格
islower()判断字母是否全都是小写
isupper()判断字母是否都是大写
isdigit()判断是否全都是数字
举个例子:
1 a = "hello8" 2 b = "world" 3 c = "123456" 4 d = "hello world" 5 e = " " 6 f = "Hello World" 7 g = "YES" 8 a1 = a.isalnum() 9 b1 = b.isalpha() 10 c1 = c.isdigit() 11 d1 = d.islower() 12 e1 = e.isspace() 13 f1 = f.istitle() 14 g1 = g.isupper() 15 print(a1) 16 print(b1) 17 print(c1) 18 print(d1) 19 print(e1) 20 print(f1) 21 print(g1)
输出结果:
True
True
True
True
True
True
True
使用方法如代码书写