C++参考代码:

#include<iostream>

#include<cstdio>

#include<cstring>

using namespace std;

int main()

{

string s;


getline(cin, s);


int len,cnt = 0;


len=s.size();


for (int i = 0; i < len; i++)

{

if (s[i] >= '0' && s[i] <= '9')

{

cnt++;

}

}


cout << cnt;


return 0;

}


python3代码:

n = input()

c = 0

for i in n:

if i.isnumeric():

c += 1

print(c)