搞个正则,然后加起来就好了。举例:
import re fru='xx2xx3xx4' test=re.findall(r'\d+', fru) test=map(int, test) print(sum(test));