def fun(s):
d={"数字":0,"字母":0,"其他":0}
for i in s:
if i.isdigit():
d["数字"]+=1
elif i.isalpha():
d["字母"]+=1
else:
d["其他"]+=1
return d
if __name__ == '__main__':
b="12,a,56,gh,%,*"
print(fun(b))
def fun(s):
d={"数字":0,"字母":0,"其他":0}
for i in s:
if i.isdigit():
d["数字"]+=1
elif i.isalpha():
d["字母"]+=1
else:
d["其他"]+=1
return d
if __name__ == '__main__':
b="12,a,56,gh,%,*"
print(fun(b))