numpy.right_shift()函数将数组元素的二进制表示形式向右移动指定的位置,并在左侧添加相等数量的0。
import numpy as np print 'Right shift 40 by two positions:' print np.right_shift(40,2) print '\n' print 'Binary representation of 40:' print np.binary_repr(40, width=8) print '\n' print 'Binary representation of 10' print np.binary_repr(10, width=8) # Two bits in '00001010' are shifted to right and two 0s appended from left.
其输出如下-
Right shift 40 by two positions: 10 Binary representation of 40: 00101000 Binary representation of 10 00001010
参考链接
https://www.learnfk.com/numpy/numpy-right-shift.html
标签:右移,Binary,right,shift,无涯,40,运算符,np,print From: https://blog.51cto.com/u_14033984/7908623