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

Re: [pygame] File Copying



Thanks everybody!

On 7/7/07, Ian Mallett <geometrian@xxxxxxxxx> wrote:
This works:

import pygame
import sys, os
from pygame.locals import *
import shutil
def main():
    shutil.copyfile("[SourceDir]", "[TargetDir]")
main()


On 7/7/07, Ian Mallett <geometrian@xxxxxxxxx> wrote:
Like how?  file("[Filepath]", "b") is invalid.


On 7/7/07, Richard Jones < richardjones@xxxxxxxxxxxxxxxx > wrote:
On Sun, 8 Jul 2007, Rolando Pereira wrote:
> 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

If you're going to do it manually like this then you must open the files
in "b"inary mode, or the images will be somewhat similar, but not the same.


    Richard