python 查找目录中的重复文件脚本
!/usr/bin/python
coding=utf-8
from hashlib
from sys
from os
from fnmatch
CHUNK_SIZE=8192
def find_specific_files(root,patterns=['*'],exclude_dirs=[]):
pass
def get_chunk(filename):
with open(filename) as f:
while True:
chunk=f.read(CHUNK_SIZE)
if not chunk:
break
else:
yield chunk
def get_file_checksum(filename):
h=hashlib.md5()
for chunk in get_chunk(filename):
h.update(chunk)
return h.hexdigest()
def main():
sys.argv.append("")
directory=sys.argv[1]
if not os.path.isdir(directory)
raise SystemExit("{0} is not a directory".format(directory))
record={}
for item in find_specific_files(directory):
checksum=get_file_checksum(item)
if checksum in record:
print('find {0} vs {1}'.format(record[checksum],item))
else:
record[checksum]=item
if name=='main':
main()
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
JavaScript常用数组操作方法,包含ES6方法
一、concat() concat() 方法用于连接两个或多个数组。该方法不会改变现有的数组,仅会返回被连接数组的一个副本。 var arr1 = [1,2,3]; var arr2 = [4,5]; var arr3 = arr1.concat(arr2); console.log(arr1); //[1, 2, 3] console.log(arr3); //[1, 2, 3, 4, 5] 二、join() join() 方法用于把数组中的所有元素放入一个字符串。元素是通过指定的分隔符进行分隔的,默认使用','号分割,不改变原数组。 var arr = [2,3,4]; console.log(arr.join()); //2,3,4 console.log(arr); //[2, 3, 4] 三、push() push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度。末尾添加,返回的是长度,会改变原数组。 var a = [2,3,4]; var b = a.push(5); console.log(a); //[2,3,4,5] console.log(b); //4...
- 下一篇
11.表达式语言
1.EL简介 EL(Expression Language): 表达式语言在JSP2.0之后,EL正式纳入标准,只要是支持Servlet2.4/JSP2.0的容器,可以直接在JSP页面中使用ELEL语法简单,使用方便,在很多地方可代替JSP标签输出page、request、session、application范围的数据 JSP表达式的代码:The outside temperature is<%= temp%> degrees表达式语言(EL)表达式的代码:The outside temperature is ${temp} degrees‘ EL是一个完全独立的拥有操作符、语法和保留字的编程语言 ’ EL隐含对象: EL隐含对象有11个,与JSP的9个隐含对象区分开与范围有关的applicationScope:sessionScope:requestScope:pageScope:与输入有关的param:paramValues:其他隐含对象cookie:header:headerValues:initParam:pageContext *通过pageContext对象可...
相关文章
文章评论
共有0条评论来说两句吧...