统计字符串里面有多少个阿拉伯数字
统计字符串里面有多少个阿拉伯数字。
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)
运行结果:
统计字符串里面有多少个阿拉伯数字。
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)
运行结果: