python实现自动备份小姐姐

import zipfile,os
path = input('Please enter the path:')
os.chdir(path)
for i in os.listdir(path):
	zip = zipfile.ZipFile(i+'.zip','w')
	if os.path.isdir(i) == True:
		for foldername,subfolders,filenames in os.walk(i):
			print('Adding files in %s...'%(foldername))
			zip.write(foldername)
			for filename in filenames:
				zip.write(os.path.join(foldername,filename))
	else:
		zip.write(i)
	zip.close()
	print('正在备份'+i+'...')
	

实现“学习视频”文件夹自动压缩备份

你可能感兴趣的:(python实现自动备份小姐姐)