File processing

Bjorn Pettersen BPettersen at NAREX.com
Tue Feb 18 11:50:39 EST 2003


> From: Peter Hansen [mailto:peter at engcorp.com] 
> 
> Bjorn Pettersen wrote:
> > 
> > > From: fishers [mailto:m.e.l at btclick.com]
> > >
> > > Hi
> > >
> > > Can Python be used to do 'high-level' file processing. 
> > > for example,
> > > appending one file to another? And if so, how?
> > 
> >   fp = open('file1', 'a')
> >   fp.write(open('file2', 'rb').read())
> >   fp.close()
> 
> Should use "ab" to open "file1" unless you want to expand \r\n
> combinations in file2 to be \r\r\n when they are added to file1...

Yes, thank you for spotting my brainfart :-)

-- bjorn





More information about the Python-list mailing list