Coursera-Python for Everybody-Using Python to Access Web Data-DatExtracting Data With Regular Expressions

Coursera-Python for Everybody-Using Python to Access Web Data-DatExtracting Data With Regular Expressions

#!/usr/bin/env python3

# -*- coding: utf-8 -*-

__author__ = 'Jhy_Bistu'

import re

#hand=open('regex_sum_42.txt')

hand=open('11.txt')

numlist=list()

for line in hand:

line=line.rstrip()

stuff=re.findall('[0-9]+',line)

if len(stuff) <1: continue

#num=map(map,[float]*len(numlist),numlist)

num = map(float, stuff)

#numlist.append(num)

numlist=numlist+num

print (numlist)

print len(numlist)

print sum(numlist)

你可能感兴趣的:(Coursera-Python for Everybody-Using Python to Access Web Data-DatExtracting Data With Regular Expressions)