作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 pyminizip
压缩和密码保护文件。 Everyting 工作正常,但我无法理解文件的解压缩。我阅读了图书馆的自述文件,但它令人困惑,解压缩对我没有帮助。这是我的代码。
压缩
pyminizip.compress("src_file", None, "dest.zip", "password", 5)
解压
pyminizip.uncompress("file.zip", "password", "dest_path", int(withoutpath))
错误
SystemError: <built-in function uncompress> returned a result with an error set
我不知道的是 uncompress()
中的第四个参数 int(withoutpath)
是什么。
官方文档说
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
请帮帮我。第四个参数真的很烦我,我无法在其他任何地方找到帮助。谢谢。
最佳答案
import pyminizip
pyminizip.compress("src_file", None, "dest.zip", "password", 5)
pyminizip.uncompress("file.zip", "password", "dest_path", 0)
//代码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;
关于Python文件压缩和解压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58336112/
为什么 pickle 重用现有的 Python 类“C”而不是从 pickle 字节重建类?有没有一种方法可以在没有副作用的情况下 pickle 和解 pickle ? 这是我的回复 session
我是一名优秀的程序员,十分优秀!