Created
July 20, 2016 00:03
-
-
Save morishjs/855359dc5e14a35370eb27d99a48da7b to your computer and use it in GitHub Desktop.
using regular expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
f = open("regex_sum_300257.txt","r") | |
lines = f.readlines() | |
sum = 0 | |
for line in lines: | |
line = line.rstrip() | |
x = re.findall('[0-9]+',line) | |
for number in x: | |
sum += int(number) | |
print sum | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment