如果妳祈求心灵的平和与快乐,就去信仰上帝!如果妳希望成为一个真理的门徒,探索吧!! -- 尼采
I can calculate the motions of havenly bodies, but not the madness of people. -- Newton
You have to be out to be in.

搜索引擎

Java, Web, Searching Engine

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  24 随笔 :: 25 文章 :: 27 评论 :: 0 Trackbacks

Set, Sequence, Dictionary << Container << Iterable

General Operation for Container, Iterable and Sequence

The built-in len function takes any container as an argument and returns the number of items in the container.

The built-in min and max functions take one argument, a nonempty iterable whose items are comparable, and return the smallest and largest items, respectively.

The built-in sum function takes one argument, an iterable whose items are numbers, and returns the sum of the numbers

You can concatenate sequences of the same type with the + operator.

ou can multiply a sequence S by an integer n with the * operator. S*n or n*S is the concatenation of n copies of S.

The x in S operator tests to check whether object x equals any item in the iterable S.
The x not in S operator is just like not (x in S).
In the specific case of strings, though, x in S is more widely applicable; in this case, the operator tests whether x equals any substring of string S, not just any single character.



Special Operation for List


L.count(x)
L.index(x)
L.append(x)
L.extend(s)
L.insert(i, x)
L.remove(x)
L.pop([i])
L.reverse( )
L.sort(cmp=cmp, key=None, reverse=False)



Special Operation for Set


S.copy( )
S.difference(S1)
S.intersection(S1)
S.issubset(S1)
S.issuperset(S1)
S.symmetric_difference(S1)
S.union(S1)
S.add(x)
S.clear( )
S.discard(x)
S.pop( )
S.remove(x)

S-S1 = difference
S&S1 = and
S^S1 = NOR
S|S1 = or



Special Operation for Dictionary


D.copy( )            
D.has_key(k)         
D.items( )           
D.keys( )            
D.values( )          
D.iteritems( )       
D.iterkeys( )        
D.itervalues( )      
D.get(k[, x])        
D.clear( )           
D.update(D1)         
D.setdefault(k[, x]) 
D.pop(k[, x])        
D.popitem( )         













posted on 2007-11-24 14:55 专心练剑 阅读(323) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。