On 07/21/2011 10:02 AM, Gary wrote:
Hi
Can someone help me with this code below please,
For some reason it will not send me the first text file in the directory.
I made up an empty file a.txt file with nothing on it and it sends the files i need but would like to fix the code.
Thanks




total = ' '
os.chdir('/home/woodygar/Desktop/Docs')
for i in os.listdir('.'):
  if '.txt' in i:
    f = open(i, 'r')
    total += f.read()
    f.close()
message = """\
Subject: %s
%s

"""% (SUBJECT,total)


Huh? Confused I am. If your first file is empty and you concatenate the contents of each file (that's what total+=f.read() does), then what do you expect to see? If you concatenate nothing (that is, the empty file), then you should see nothing. I see no problem with the code, but perhaps a problem with your expectations.

If I've misunderstood your question, the please reword and resend it, but this time include more information: The files in '.', their content, the output you do get, and the output you expected.

Gary Herron


--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to