压缩.log 文件为zip后删除原文件 需要注意:本人作为小白,该脚本需要和.log在一起,后面有时间需要改正. #!/usr/local/python/bin/python #-*-coding=utf8 -*- import time import os import sys import zipfile N = 7 #设置删除多少天前的文件 def zip(srcpath): for folder,sumfolder,files in os.walk(srcpath): for file
# -*- coding: utf-8 -*- #python 27 #xiaodeng #Python之zip #http://python.jobbole.com/82590/ #1)zip语法格式: ''' zip(...) zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)] Return a list of tuples, where each tuple contains the i-th element from e
import os import time import sys from xml.dom import minidom, Node from xml.dom.minidom import parse,parseString from stat import * import xml.etree.ElementTree as ET #删除1day前的日志 def DelLog(filepath): if not os.path.isdir(filepath) and not os.path.is
定义:zip([iterable, …])zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),然后返回由这些tuples组成的list(列表).若传入参数的长度不等,则返回list的长度和参数中长度最短的对象相同.利用*号操作符,可以将list unzip(解压),看下面的例子就明白了: >>> a = [1,2,3,4] >>> b = [5,6,7,8] >>> c = [5,
reprinted:http://www.cnblogs.com/beginman/archive/2013/03/14/2959447.html A. code talk is cheap ,show you the code first: 1 >>> name=('jack','beginman','sony','pcky') 2 >>> age=(2001,2003,2005,2000) 3 >>> for a,n in zip(name,age