[Tutor] String Attribute
ltc.hotspot at gmail.com
ltc.hotspot at gmail.com
Fri Jul 31 00:51:54 CEST 2015
Hi Mark,
I’m still confused because line 4 reads: fh=open(fname,'r') # Open a new
file handle, not fn = open(fname)
Therefore, can you write down line by line from error to correction?
Here is the revised code:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt" # assign fname
fh=open(fname,'r') # Open a new file handle
for line in fh:
print line
if 'From' in line.split()[0] and '@' in line: sender = line.split()[2]
print sender
Regards,
Hal
Sent from Surface
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list