def String(string):
big = ()
small = ()
num = ()
other = ()
for i in string:
if i.isupper():
big += (i, )
elif i.islower():
small += (i, )
elif i.isnumeric():
num += (i, )
else:
other += (i, )
return (len(big), len(small), len(num), len(other))
a_str = "234FS4DG,J,Fvg4fd"
a_touple = String(a_str)
print(a_touple)
编写一个函数,计算一个字符串中大写字母,小写字母,数字,其他字符各有多少个,函数的返回值是以元组的形式
猜你喜欢
转载自blog.csdn.net/weixin_45116412/article/details/105063648
今日推荐
周排行