Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2008-06-20 03:10:55
Size: 1012
Editor: ZoomQuiet
Comment:
Revision 3 as of 2009-12-25 07:17:58
Size: 945
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
[[TableOfContents]] <<TableOfContents>>
Line 6: Line 6:
[[Include(ZPyUGnav)]] <<Include(ZPyUGnav)>>
Line 44: Line 44:
创建 by -- ZoomQuiet [[[DateTime(2008-06-20T03:10:55Z)]]]
||<^>[[PageComment2]]||<^>[:/PageCommentData:PageCommentData]''||
创建 by -- ZoomQuiet [<<DateTime(2008-06-20T03:10:55Z)>>]

去掉两个列表中的公共元素

Boern <[email protected]>
reply-to        [email protected]
to      [email protected]
date    Thu, Jun 19, 2008 at 09:45
subject [CPyUG:55253] 如何把两个列表中的公共元素去掉?

如题,现在如果有 a=[1,2,3] ;b= [2,3,4] ,有没有最简单的方法把 a,b 中共有的 2,3元素去掉,之后 a=[1],b=[4]?

马踏飞燕 二法

马踏飞燕 <[email protected]>

法一

   1 a = list(set(a)-set(b))
   2 b = list(set(b)-set(a))
法二

   1 a = list(set(a) - (set(a) and set(b)))
   2 b= list(set(b) - (set(a) and set(b)))


反馈

创建 by -- ZoomQuiet [2008-06-20 03:10:55]

MiscItems/2008-06-20 (last edited 2009-12-25 07:17:58 by localhost)