1个回答
展开全部
Python 3.6.1 (default, Sep 7 2017, 16:36:03)
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s = '123 456 7 4'
>>> import re
>>> a = re.findall(r'\d+', s)
>>> a
['123', '456', '7', '4']
>>> sum([int(i) for i in a])
590
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询