在Python中将所有具有相似名称的文件一起压缩

时间:2016-01-08 20:17:34

标签: python python-2.7 zip

我正在尝试压缩以' scan'开头的所有文件。进入scan.zip。 同样的文件以' mpg'开头。进入mpfg.zip。我有5-6个其他扩展名,如.txt .jpg,可以在tzt.zip,jpg.zip等中压缩。

目前,我有一个node_seen循环来完成这项工作,但我想知道在python 2.7中是否有更智能的1-2衬管命令来实现这一目标。

Create TaskTree with only this node.
Add this TaskTree to the node_seen map

If this node's ID is in the parent_needed map:
    Add each tree in the parent_needed map to this tree
    Remove this node's ID from the parent_needed map

If this node has no parent:
    Add this node's tree to the root tree
Else if this node's parent ID is in the node_seen map:
    Add this node's tree to the parent tree
Else if this node's parent_ID is in the parent_needed map:
    Append this node's tree to the parent_needed vector
Else:
    Create a vector containing this node's tree
    Add a mapping from this node's parent ID to that vector in the parent_needed map

0 个答案:

没有答案