[Tutor] Errno 9
imonthejazz
imonthejazz at googlemail.com
Thu Feb 28 15:36:55 CET 2008
Hi All,
I am trying to read a line in a file then split the words in the line up.
This is what i thought would work:
# filearray.py
import string
# THE FOLLOWING FOUR LINE ARE THE CORRECT START TO THE PROGRAM,
# THE SIXTH AND SEVENTH LINES ARE ONLY FOR QUICK TEST PURPOSE!!!
infilename = raw_input("What file would you like to re-arrange?: ")
outfilename = raw_input("Where would you like to save to array?: ")
infile = open(infilename, 'r')
infile = open(outfilename, 'w')
#infile = open("G:\gnet.nmap", 'r')
#infile = open("G:\work2.txt", 'w')
# process each line
for line in infile.readlines():
words = string.split(line)
print words
# save and close files
infile.close()
infile.close()
But i get an "IO Error: [Errno 9] Bad file descriptor" on line 16.
Tried changing syntax and file names, thought it was fairly simple and i
knew what i was doing. Any help appreciated.
Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080228/2ee97ebd/attachment.htm
More information about the Tutor
mailing list