numpy矩阵
In [20]: cmp(10,2) #
cmp(x,y):Out[20]: 1
In [21]: cmp(10,22)
Out[21]: -1
In [22]: cmp(10,10)
Out[22]: 0
In [3]: import numpy as np
In [4]: a1=np.array([1,2,3],dtype=int)
In [5]: a2=np.array([[1,2,3],[2,3,4]])
In [6]: b1=np.zeros((2,3))
- In [7]: b1
Out[7]:
array([[ 0., 0., 0.],
[ 0., 0., 0.]])
In [8]: a2
Out[8]:
array([[1, 2, 3],
[2, 3, 4]])
In [9]: a1
Out[9]: array([1, 2, 3])
compile(source, filename, mode[, flags[, dont_inherit]])
Compile the source into a code or AST object. Code objects can be executed by an exec statement or evaluated by a call to eval().source can either be a Unicode string, a Latin-1 encoded string or an AST object. Refer to the ast module documentation for information on how to work with AST objects.
divmod(a, b)
Take two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using long division. With mixed operand types, the rules for binary arithmetic operators apply. For plain and long integers, the result is the same as (a // b, a % b). For floating point numbers the result is (q, a % b), where q is usually math.floor(a / b) but may be 1 less than that. In any case q * b + a % b is very close to a, if a % b is non-zero it has the same sign as b, and 0 <= abs(a % b) < abs(b).