[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] File Copying



OK, that worked the first time I tried it, but the file was not valid, i.e. corrupted.

On 7/7/07, Rolando Pereira < finalyugi@xxxxxxx> wrote:
Ian Mallett escreveu:
> Hi,
> Suppose you have an image file.  Call it " blah.png".  If I want to copy it
> to another directory and rename it "Ogg.png", how would I do that with
> python code?
>

Well, this is more of a [Tutor]'s question than a Pygame's question, but
at least this one I can anwser.

(This was done in 5 minutes or so, so it might have a but or something :D )

f = file("full_path_to_blah.png")
n = file("full_path_to_Ogg.png", "w") # We add "w", so that if
the file                                                so that if the file doesn't                                                     exist, it will be created

n.write(f.read())
n.close()

Presto, there should be now two similar images :D

--
                        _
ASCII ribbon campaign ( )
  - against HTML email  X
              & vCards / \