1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| import re
from time import clock
bla = re.compile('<td colspan=3 class="individualName">(.+?)</td>')
nbtours = 40
li1 = []
somme = 0
for fois in range(nbtours):
t0 = clock()
f = open('riscuanov1','r')
for ligne in f:
m = bla.search(ligne)
if m is not None:
recup = m.group(1)
li1.append(recup)
f.close()
somme = somme + clock()-t0
print clock()-t0
print li1
print 'nombre de fois =',nbtours,' temps moyen =',somme/nbtours
li2 = []
somme = 0
for fois in range(nbtours):
t0 = clock()
f = open('riscuanov1','r')
for ligne in f:
if '<td colspan=3 class="individualName">' in ligne and '</td>' in ligne:
recup = ligne.partition('individualName">')[2].partition('</td>')[0]
li2.append(recup)
f.close()
somme = somme + clock()-t0
print clock()-t0
print li2
print 'nombre de fois =',nbtours,' temps moyen =',somme/nbtours |
Partager