reading/writing files

sandipm sandip.more at gmail.com
Tue Nov 27 08:14:14 EST 2007


f1= open("file1.pdf", "rb")
x = f1.read()
open("file2.pdf", "wb").write(x)



works...

thanks
sandip

On Nov 27, 5:43 pm, sandipm <sandip.m... at gmail.com> wrote:
> Hi,
>
>   I am trying to read a file and write into other file. if I do it for
> simple text file, it works well.
> but for pdfs or some other mime types, its failing.
>
> actually main problem is i am uploading file using cgi, in this
> process I am getting content of file, and I am
> trying to save the file. I think I need to specify mimetype of file
> somehow..?
> any quick solutions? or need to google.
>
> sandip




More information about the Python-list mailing list