intcount = [] |
upstrcount = [] |
lowstrcount = [] |
othercount = [] |
def number(a): |
for i in a: |
if i.isdigit(): |
intcount.append(i) |
elif i.isupper(): |
upstrcount.append(i) |
elif i.islower(): |
lowstrcount.append(i) |
else : |
othercount.append(i) |
return intcount,upstrcount,lowstrcount,othercount |
a = input ( '请输入一个字符串:' ) |
a,b,c,d = number(a) |
print ( '大写字母的个数:{}' . format ( len (a))) |
print ( '小写字母的个数:{}' . format ( len (b))) |
print ( '数字的个数:{}' . format ( len (c))) |
print ( '其他数字的个数:{}' . format ( len (d))) |
a = tuple (a) |
b = tuple (b) |
c = tuple (c) |
d = tuple (d) |
print (a,b,c,d) |
———————————————— |
版权声明:本文为CSDN博主「小小cccccc」的原创文章,遵循CC 4.0 BY - SA版权协议,转载请附上原文出处链接及本声明。 |
原文链接:https: / / blog.csdn.net / weixin_46007559 / article / details / 106152761 |