这适用于 Python 2:
import re
print sum([int(i) for i in re.findall('[0-9]+',open(raw_input('What is the file you want to analyze?\n'),'r').read())])
但是为什么我在使用 Python 3 时会出现语法错误?
Python3
import re
print sum([int(i) for i in re.findall('[0-9]+',open(input('What is the file you want to analyze?\n')).read())])
Helenr
相关分类