1
Sanko 2020-05-30 14:07:10 +08:00
给个例子
|
2
Zhepro OP |
3
tom8 2020-05-30 14:21:14 +08:00
def splitss(str):
sum = 0 for i in str.split('\n'): sum += int(i) return sum |
4
ipwx 2020-05-30 14:24:32 +08:00
S = '''66
82 124 125''' print(sum(map(int, S.split('\n')))) ---- 话说但凡看完了 Python 教程都不至于不会写这个吧? |
7
yucongo 2020-05-30 16:45:26 +08:00
sum(int(elm) for elm in S.split())
或 sum(int(elm) for elm in re.findall(r'\d+', S)) |