[英]Python file zipping and unzipping
I am using pyminizip
to zip and password protect a file.我正在使用
pyminizip
到 zip 和密码保护文件。 Everyting is working fine but I am not able to understand the unzipping of files. Everyting 工作正常,但我无法理解文件的解压缩。 I read the library's README but it is confusing and the unzipping is not helping me.
我阅读了图书馆的自述文件,但它令人困惑,解压缩对我没有帮助。 Here is my code.
这是我的代码。
Zipping拉链
pyminizip.compress("src_file", None, "dest.zip", "password", 5)
Unzipping解压
pyminizip.uncompress("file.zip", "password", "dest_path", int(withoutpath))
ERROR错误
SystemError: <built-in function uncompress> returned a result with an error set
What I dont know is what is the fourth argument, int(withoutpath)
in the uncompress()
.我不知道
uncompress()
中的第四个参数int(withoutpath)
是什么。
The official docs say官方文档说
pyminizip.compress("/srcfile/path.txt", "file_path_prefix", "/distfile/path.zip", "password", int(compress_level))
Args:
1. src file path (string)
2. src file prefix path (string) or None (path to prepend to file)
3. dst file path (string)
4. password (string) or None (to create no-password zip)
5. compress_level(int) between 1 to 9, 1 (more fast) <---> 9 (more compress) or 0 (default)
Return value:
- always returns None
pyminizip.compress_multiple([u'pyminizip.so', 'file2.txt'], [u'/path_for_file1', u'/path_for_file2'], "file.zip", "1233", 4, progress)
Args:
1. src file LIST path (list)
2. src file LIST prefix path (list) or []
3. dst file path (string)
4. password (string) or None (to create no-password zip)
5. compress_level(int) between 1 to 9, 1 (more fast) <---> 9 (more compress)
6. optional function to be called during processing which takes one argument, the count of how many files have been compressed
Return value:
- always returns None
pyminizip.uncompress("/srcfile/path.zip", "password", "/dirtoextract", int(withoutpath))
1. src file path (string)
2. password (string) or None (to unzip encrypted archives)
3. dir path to extract files or None (to extract in a specific dir or cwd)
4. withoutpath (exclude path of extracted)
Return value:
- always returns None
Kindly help me out.请帮帮我。 The fourth argument is really bugging me out and I am not able to find help anywhere else.
第四个论点真的让我很烦,我无法在其他任何地方找到帮助。 Thank you.
谢谢你。
import pyminizip
pyminizip.compress("src_file", None, "dest.zip", "password", 5)
pyminizip.uncompress("file.zip", "password", "dest_path", 0)
// code https://github.com/smihica/pyminizip/blob/master/src/py_miniunz.c#L227 // 代码https://github.com/smihica/pyminizip/blob/master/src/py_miniunz.c#L227
if ((*popt_extract_without_path)==0)
write_filename = filename_inzip;
else
write_filename = filename_withoutpath;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.