def he(s):
l = 0
#遍历
for i in s:
#如果是数字
if i.isdecimal():
#转换整数
i=int(i)
#不是整数
else:
#变成0
i=0
#相加
l=l+i
return l
print(he(s))
计算一个字符串中所有数字的和(连续的数字不看成一个整数)
猜你喜欢
转载自blog.csdn.net/weixin_43788061/article/details/87437475
今日推荐
周排行