$ echo "short"|zip -z test.zip enter new zip file comment (end with .): $ md5sum test.zip 48da9079a2c19f9755203e148731dae9 test.zip $ echo "longlong"|zip -z test.zip current zip file comment is: short enter new zip file comment (end with .): $ md5sum test.zip 3618846524ae0ce51fbc53e4b32aa35b test.zip $ echo "short"|zip -z test.zip current zip file comment is: longlong enter new zip file comment (end with .): root@Debian:~# md5sum test.zip 48da9079a2c19f9755203e148731dae9 test.zip $ echo "longlong"|zip -z test.zip current zip file comment is: short enter new zip file comment (end with .): $ md5sum test.zip 3618846524ae0ce51fbc53e4b32aa35b test.zip $ $ $ cat test.py #/usr/bin/env python #coding: utf-8 import zipfile import subprocess zip_name = 'test.zip' def add_comment(zip_name, comment): with zipfile.ZipFile(zip_name, 'a') as zf: zf.comment = comment add_comment(zip_name, "short") print subprocess.Popen(['md5sum', zip_name], stdout=subprocess.PIPE).communicate()[0], add_comment(zip_name, "longlong") print subprocess.Popen(['md5sum', zip_name], stdout=subprocess.PIPE).communicate()[0], add_comment(zip_name, "short") print subprocess.Popen(['md5sum', zip_name], stdout=subprocess.PIPE).communicate()[0], add_comment(zip_name, "longlong") print subprocess.Popen(['md5sum', zip_name], stdout=subprocess.PIPE).communicate()[0], $ $ python test.py 48da9079a2c19f9755203e148731dae9 test.zip 3618846524ae0ce51fbc53e4b32aa35b test.zip 89c2038501f737991ca21aa097ea9956 test.zip 3618846524ae0ce51fbc53e4b32aa35b test.zip At shell env, the fist time and the third time, "test.zip" md5 values are the same, the second time and the forth time, "test.zip" md5 values are the same, but when i use python zipfile, the result is not like that. How can I do this with the Python zipfile module? Continue reading...