1. 查看模块帮助
  2. Windows下文件和文件夹的处理
  3. 查看文件夹下所有文件的总大小,包括子目录的递归

    import os
    sizeList = []
    #
    def get_size(path):
    fileList = os.listdir(path)
    for filename in fileList:
        pathTemp = os.path.join(path, filename)
        if os.path.isdir(pathTemp):
            get_size(pathTemp)
        elif os.path.isfile(pathTemp):
            fileSize = os.path.getsize(pathTemp)
            print('Directory %s size is : %d' %(pathTemp, fileSize))
            sizeList.append(fileSize)       
    #
    path = input("please input path: ").strip()
    get_size(path)
    print("all size is :%d bytes" % sum(sizeList))
  4. copy文件夹
    例:将test目录下的所有文件拷贝到目录test1下
    import shutil, os
    os.chdir('d:\\')
    shutil.copytree('d:\\test', 'd:\\test1')