rootlen = len(target_dir) + 1
for base, dirs, files in os.walk(target_dir):
    for file in files:
        fn = os.path.join(base, file)
zipobj.write(fn, fn[rootlen:])
zipfolder('thenameofthezipfile', 'thedirectorytobezipped')
sys.exit()
ZIP folder with subfolder in python