创建函数:
'''
首先需要引入 os shutil模块
'''
def copy_dir(self, dir1, dir2):
dlist = os.listdir(dir1)
if not os.path.exists(dir2):
os.mkdir(dir2)
for f in dlist:
file1 = os.path.join(dir1, f) # 源文件
file2 = os.path.join(dir2, f) # 目标文件
if os.path.isfile(file1):
shutil.copyfile(file1, file2)
if os.path.isdir(file1):
self.copy_mulu(file1, file2)



