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 di
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/13 00:14:32
![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 di](/uploads/image/z/12301266-66-6.jpg?t=python+string+%E6%B1%82%E6%95%99%EF%BC%9Afunction+name+%EF%BC%9Acount_digits%3A%28str%29+-%3E+int%E6%8F%8F%E8%BF%B0%EF%BC%9AReturn+the+total+number+of+characters+in+the+given+string+that+are+digits.For+example%2Cthe+String+%27123abc456%27+has+3+characters+which+are+non-digits%2Cand+6+characters+which+are+di)
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 di
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.
这个应该怎写?
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 di
def count_digits(str):
count = 0
for c in str:
if c.isdigit():count += 1
return count