Movatterモバイル変換


[0]ホーム

URL:


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.23 shutilUp:6.23 shutilNext:6.24 locale

 
6.23.1 Example

This example is the implementation of thecopytree()function, described above, with the docstring omitted. Itdemonstrates many of the other functions provided by this module.

def copytree(src, dst, symlinks=0):    names = os.listdir(src)    os.mkdir(dst)    for name in names:        srcname = os.path.join(src, name)        dstname = os.path.join(dst, name)        try:            if symlinks and os.path.islink(srcname):                linkto = os.readlink(srcname)                os.symlink(linkto, dstname)            elif os.path.isdir(srcname):                copytree(srcname, dstname, symlinks)            else:                copy2(srcname, dstname)        except (IOError, os.error), why:            print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.23 shutilUp:6.23 shutilNext:6.24 locale
Release 2.2.3, documentation updated on 30 May 2003.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2026 Movatter.jp