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/11/01 20:26:42
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
xRN0mC)tҰqRD 10BHepl @>{nP)\F%d y}]$( !I4/%"`X/(Jr#Y,)(B)m&"GW(~+`'$+l؊7ٚnzi ʭ a*Ao-{REm8ZFhV.na&ffN4 æ}%f'nofr,|'ߘIJʵaa;s,f

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