@tripleee 's@tripleee's answer helped me, so I putsee my test in the below, hope it will help also.
The following oneThis code works for me, on python 3.5.2, windows8 on Windows 8.1, 7z ( 7z path added to system).
rc = subprocess.call(['7z', 'a', output_filename + '.zip', '-mx9', '-pSecret^)'] + [src_folder + '/'])
With two parameters, -mx9 means max compression, -pSecret^) means password is "Secret^)" , "^" is escape for ")"for windows system, but when you unzip, it will need type in the "^".:
-mx9
means max compression-pSecret^)
means password isSecret^)
.^
is escape for)
for Windows OS, but when you unzip, it will need type in the^
.
Without "^", windows system^
Windows OS will not apply the password when 7z.exe creating the zipzip file.
Also, if you want to use "-mhe"-mhe
switch, youyou'll need the file format to be in 7z7z instead of zipzip.
I hope that may help.