Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1637993
  • 博文数量: 126
  • 博客积分: 1541
  • 博客等级: 上尉
  • 技术积分: 1914
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-20 11:14
文章分类

全部博文(126)

文章存档

2014年(21)

2013年(42)

2012年(63)

分类:

2013-01-08 21:24:25

In [11]: import operator

In [13]: a=[1,2,3]

In [14]: b=[4,5,6]

In [15]: c=map(operator.mul,a,b)

In [16]: print c
[4, 10, 18]

In [17]: c=map(operator.add,a,b)

In [18]: print c
[5, 7, 9]

In [20]: c=map(operator.and_,a,b)  

In [21]: print c
[0, 0, 2]

In [23]: c=map(operator.abs,a)

In [24]: print c
[1, 2, 3]


   abs(...)
        abs(a) -- Same as abs(a).
   
    add(...)
        add(a, b) -- Same as a + b.
   
    and_(...)
        and_(a, b) -- Same as a & b.
   
    concat(...)
        concat(a, b) -- Same as a + b, for a and b sequences.
   
    contains(...)
        contains(a, b) -- Same as b in a (note reversed operands).
   
    countOf(...)
        countOf(a, b) -- Return the number of times b occurs in a.
   
    delitem(...)
        delitem(a, b) -- Same as del a[b].
   
    delslice(...)
        delslice(a, b, c) -- Same as del a[b:c].
   
    div(...)
        div(a, b) -- Same as a / b when __future__.division is not in effect.
   
    eq(...)
        eq(a, b) -- Same as a==b.
   
    floordiv(...)
        floordiv(a, b) -- Same as a // b.
   
    ge(...)
        ge(a, b) -- Same as a>=b.
   
    getitem(...)
        getitem(a, b) -- Same as a[b].
   
    getslice(...)
        getslice(a, b, c) -- Same as a[b:c].
   
    gt(...)
        gt(a, b) -- Same as a>b.
   
    iadd(...)
        iadd(a, b) -- Same as a += b.
   
    iand(...)
        iand(a, b) -- Same as a &= b.
   
    iconcat(...)
        iconcat(a, b) -- Same as a += b, for a and b sequences.
   
    idiv(...)
        idiv(a, b) -- Same as a /= b when __future__.division is not in effect.
   
    ifloordiv(...)
        ifloordiv(a, b) -- Same as a //= b.
   
    ilshift(...)
        ilshift(a, b) -- Same as a <<= b.
   
    imod(...)
        imod(a, b) -- Same as a %= b.
   
    imul(...)
        imul(a, b) -- Same as a *= b.
    index(...)
        index(a) -- Same as a.__index__()
   
    indexOf(...)
        indexOf(a, b) -- Return the first index of b in a.
   
    inv(...)
        inv(a) -- Same as ~a.
   
    invert(...)
        invert(a) -- Same as ~a.
   
    ior(...)
        ior(a, b) -- Same as a |= b.
   
    ipow(...)
        ipow(a, b) -- Same as a **= b.
   
    irepeat(...)
        irepeat(a, b) -- Same as a *= b, where a is a sequence, and b is an integer.
   
    irshift(...)
        irshift(a, b) -- Same as a >>= b.
   
    isCallable(...)
        isCallable(a) -- Same as callable(a).
   
    isMappingType(...)
        isMappingType(a) -- Return True if a has a mapping type, False otherwise.
   
    isNumberType(...)
        isNumberType(a) -- Return True if a has a numeric type, False otherwise.
   
    isSequenceType(...)
        isSequenceType(a) -- Return True if a has a sequence type, False otherwise.
   
    is_(...)
        is_(a, b) -- Same as a is b.
    is_not(...)
        is_not(a, b) -- Same as a is not b.
   
    isub(...)
        isub(a, b) -- Same as a -= b.
   
    itruediv(...)
        itruediv(a, b) -- Same as a /= b when __future__.division is in effect.
   
    ixor(...)
        ixor(a, b) -- Same as a ^= b.
   
    le(...)
        le(a, b) -- Same as a<=b.
   
    lshift(...)
        lshift(a, b) -- Same as a << b.
   
    lt(...)
        lt(a, b) -- Same as a
   
    mod(...)
        mod(a, b) -- Same as a % b.
   
    mul(...)
        mul(a, b) -- Same as a * b.
   
    ne(...)
        ne(a, b) -- Same as a!=b.
   
    neg(...)
        neg(a) -- Same as -a.
   
    not_(...)
        not_(a) -- Same as not a.
   
    or_(...)
        or_(a, b) -- Same as a | b.
    pos(...)
        pos(a) -- Same as +a.
   
    pow(...)
        pow(a, b) -- Same as a ** b.
   
    repeat(...)
        repeat(a, b) -- Return a * b, where a is a sequence, and b is an integer.
   
    rshift(...)
        rshift(a, b) -- Same as a >> b.
   
    sequenceIncludes(...)
        sequenceIncludes(a, b) -- Same as b in a (note reversed operands; deprecated).
   
    setitem(...)
        setitem(a, b, c) -- Same as a[b] = c.
   
    setslice(...)
        setslice(a, b, c, d) -- Same as a[b:c] = d.
   
    sub(...)
        sub(a, b) -- Same as a - b.
   
    truediv(...)
        truediv(a, b) -- Same as a / b when __future__.division is in effect.
   
    truth(...)
        truth(a) -- Return True if a is true, False otherwise.
   
    xor(...)
        xor(a, b) -- Same as a ^ b.
阅读(4702) | 评论(0) | 转发(0) |
0

上一篇:Python 之ConfigParser

下一篇:python len sys.argv

给主人留下些什么吧!~~