统计字符串里面有多少个阿拉伯数字

 

统计字符串里面有多少个阿拉伯数字。

s = "I am sylar, I'm 14 years old, I have 2 dogs!"
count = 0
for c in s:
if c.isdigit():
count = count + 1
print(count)

运行结果:

 

posted @ 2023-11-05 21:31  Thomas2023  阅读(17)  评论(0编辑  收藏  举报