Python文件夹备份
Python文件夹备份
import os,shutil
def file_copy(path1,path2):
f2 = [filename1 for filename1 in os.listdir(path2)]
for filename in os.listdir(path1):
if filename not in f2 :
#判断是否源文件是否在备份文件夹内存在
path3= os.path.join(path1,filename)
path4=os.path.join(path2,filename)
shutil.copy(path3,path4)
#同步文件