求两个列表的差集 >>> a = [1,2,3] >>> b=[1,2] >>> #################################### >>> #两个列表的差集 >>> ret = [] >>> for i in a: if i not in b: ret.append(i) >>> ret [3] >>> #两个列表的差集2 >>…
假设我们现在有两个文件 a.txt .b.txt a.txt 中的内容如下: a c 1 3 d 4 b.txt 中的内容如下: a b e 2 1 5 # Example 01 计算并集: [root@VM_81_181_centos ~]# sort -u a.txt b.txt 1 2 3 4 5 a b c d e [root@VM_81_181_centos ~]# # Exmaple 02 计算交集: [root@VM_81_181_centos ~]# grep -F -f a.t…
比较文件夹diff,可以直接使用diff命令 [root@~]# diff -urNa dir1 dir2 -a Treat all files as text and compare them line-by-line, even if they do not seem to be text. -N, --new-file In directory comparison, if a file is found in only one directory, treat it as present…
使用comm命令 假设两个文件FILE1和FILE2用集合A和B表示,FILE1内容如下: a b c e d a FILE2内容如下: c d a c 基本上有两个方法,一个是comm命令,一个是grep命令.分别介绍如下: comm命令 , Compare sorted files FILE1 and FILE2 line by line. With no options, produce three-column output. Column one contains lines un…
Oracle 取两个表中数据的交集 关键字: Oracle 取两个表中数据的交集 INTERSECT Oracle 作为一个大型的关系数据库,日常应用中往往需要提取两个表的交集数据 例如现有如下表,要求找出工资2500(不含2500)以上并且是男性(M)的员工编号,那么就要利用这两个表的关系做一个交集了 employee CODE NAME GENDER 001 Tom M 002 Jerry M 003 Ana F salary CODE SALARY 001 2800 002 2500 00…
http://www.jb51.net/article/40385.htm 代码如下: /** * each是一个集合迭代函数,它接受一个函数作为参数和一组可选的参数 * 这个迭代函数依次将集合的每一个元素和可选参数用函数进行计算,并将计算得的结果集返回 {%example <script> var a = [1,2,3,4].each(function(x){return x > 2 ? x : null}); var b = [1,2,3,4].each(function(x){re…
http://blog.csdn.net/autofei/article/details/6579320 假设两个文件FILE1和FILE2用集合A和B表示,FILE1内容如下: a b c e d a FILE2内容如下: c d a c 基本上有两个方法,一个是comm命令,一个是grep命令.分别介绍如下: comm命令 , Compare sorted files FILE1 and FILE2 line by line. With no options, produce three-…
在项目中遇到要取两个表差集的情况 假设有两个表tblNZPostCodes, NZPostcode 两个表中存储的都是新西兰的post code信息,字段一致,只是数据上有所差异. 1. Union 获取两个表的合集并且自动过滤重复数据 Select * from tblNZPostCodes Union Select * from NZPostcode 2. Union all 获取两个表的合集并且不过滤重复数据 Select * from tblNZPostCodes Union all…