文件合并例子


                功能:文件合并的例子
               
               
                #!/usr/bin/env python
#merge all files into one file
import time
start = time.clock()
#open file for writing
outfile = file("output.py",'w')
for infile in ['JoinBigFile.py','JoinBigFile.py','JoinBigFile.py','JoinBigFile.py']:
    fp = file(infile)
    #read file contents and append it
    outfile.write(fp.read())
    fp.close()
outfile.close()
end = time.clock()
print end - start
time模块使用,显示合并所需要的时间,单位秒。
from:
http://mail.python.org/mailman/listinfo/python-list