python string

问题描述:

python string
求教:function name :
count_digits:
(str) -> int
描述:Return the total number of characters in the given string that are digits.For example,the String '123abc456' has 3 characters which are non-digits,and 6 characters which are digits.
这个应该怎写?
1个回答 分类:英语 2014-09-27

问题解答:

我来补答
def count_digits(str):
count = 0
for c in str:
if c.isdigit():count += 1
return count
 
 
展开全文阅读
剩余:2000
上一页:单调性最小值
下一页:溶质质量