求输入一串字符串中的数字和

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/feiYu12138/article/details/81773013
# str1 = input()
# s = 0
# for i in str1:
#     if i.isdigit():
#         s += int(i)
# print(s)


str2 = input()
str3 = ""
for i in str2:
    if i.isdigit():
        str3 += i
    else:
        str3 += " "
list1 = str3.split()
s = 0
for i in list1:
    s += int(i)
print(s)



展开阅读全文

没有更多推荐了,返回首页