统计字符串中各个字符的个数
思路:用了count方法统计,for循环各个字符
str = input (“输入”)
asd123
result ={}
for i in str:
result[i]=str.count(i)
print(result)
统计输入字符中,数字,字母,其他的个数
思路:用三种发放,for循环统计,elif 判断
str = input(“输入”)
int_count = 0
str_count = 0
other_count = 0
for i in str:
if i.isdidit():
int_count +=1
elif i.isalnum():
str_count +=1
else:
other_count +=1
print (int_count,str_count,other_count)