
August 1st, 2003, 09:30 AM
|
|
Junior Member
|
|
Join Date: Aug 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
saving files
I have a simple question...I think..
I need to go through my current directory, finding files who have their file name IN the actual file somewhere. And the list of files who do, need to be stored in another file given as the scripts argument. I just need to know how to save output to a file (that file specified on the command line). Here is what I have, but the
#!/usr/bin/python
import os,sys,string
file_lst = os.listdir(".")
print file_lst
infile=open(sys.argv[1])
if infile is None:
print 'Error'
for file in file_lst:
if os.path.isfile(file):
fd=open(file,'r')
str=fd.read()
if string.find(str,file)>-1
print file
infile=file.save(file)
the last line is where it doesn't work. I can print these to screen but not save them to a file
|