Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exercise 7.1
- # -*- coding: iso-8859-15 -*-
- fasa = open('/home/fer/mbox-short.txt')
- for linea in fasa:
- print linea.upper()
- fasa.close() #just to get used to it
- Exercise 7.2
- # -*- coding: iso-8859-15 -*-
- nombref = raw_input("Nombre de archivo: ")
- try:
- fasa = open(nombref)
- count=0
- total=0
- num=0
- for linea in fasa:
- if linea.startswith("X-DSPAM-Confidence:"):
- num = linea[20:26]
- num = float(num)
- total = total + num
- count +=1
- print "Total sum ", total
- print "Number of lines ", count
- except:
- print "file %s can not be opened" % nombref
- Exercise 7.3
- # -*- coding: iso-8859-15 -*-
- nombref = raw_input("Nombre de archivo: ")
- try:
- fasa = open(nombref)
- count=0
- total=0
- num=0
- for linea in fasa:
- if linea.startswith("X-DSPAM-Confidence:"):
- num = linea[20:26]
- num = float(num)
- total = total + num
- count +=1
- print "Total sum ", total
- print "Number of lines ", count
- except:
- if nombref =='na na boo boo':
- print "NA NA BOO BOO TO YOU - You have been punk'd!"
- else:
- print "file %s can not be opened" % nombref
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement