s = input('请输入') count = 0 for i in s: if i.isdigit(): count += 1 print(count)
升级版 字符串中连在一起的数字算一个
s = input('请输入') for i in s: if i.isalpha(): s = s.replace(i,' ') s = s.split() print(len(s))