文件打包
def zip(dirname,filename):
zip = zipfile.ZipFile(filename,'w',zipfile.ZIP_DEFLATED)
for root,dirs,files in os.walk(dirname,topdown=False ):
for filename in files:
zip.write(os.path.join(root,filename).encode('gbk'))
if len(files) == 0:
print 'empty dir'
zif = zipfile.ZipInfo((root+ os.sep).encode('gbk'))
zip.writestr(zif,'')
zip.close()