#!/usr/bin/env python3
#coding:utf-8

import zipfile,os

def get_zip_file(input_path,result):
	files = os.listdir(input_path)
	for file in files:
		if os.path.isdir(input_path+'/'+file):
			get_zip_file(input_path+'/'+file,result)
		else:
			result.append(input_path+'/'+file)

def zip_path(input_path,output_path,output_name):
	f = zipfile.ZipFile(output_path+'/'+output_name,'w',zipfile.ZIP_DEFLATED)
	filelists = []
	get_zip_file(input_path,filelists)
	for file in filelists:
		f.write(file)
	f.close()
	return output_path+"/"+output_name

if __name__ == '__main__':
	zip_path(r".","/tmp/test",'pythonzip.zip')









