判断字符串列表中首字母是否大写,并输出所以首字母大写的值

使用过滤器filter筛出所有的小写字母:

X.istitle()  #判断X中是否有小写的字母

list_x=['aaaaa','Aa','bddB','Bbaaa','cD','Bd','A']
r=filter(lambda x:x if x.istitle() else False,list_x)
print(list(r))

tips:结合上一篇可以过滤/判断出是否带有小写/大写字母或数字或首字母大写的值


上一篇:python3判断字符串是字母/数字/大小写的系统函数


猜你喜欢

转载自blog.csdn.net/godot06/article/details/80966795
今日推荐