2021
01-09
01-09
利用python查看数组中的所有元素是否相同
不知道大家有没有过这种经历,就是想要判断两个数组运算后得到的新数组中的各个元素值是否相同。这里给出一种使用np.unique()的方法,代码如下:importnumpyasnpclassDebug:@staticmethoddefisAllElementSame():x1=np.array([[1,2,3],[3,4,5],[6,7,8]])x2=np.array([[81.,162.,243.,],[243.,324.,405.],[486.,567.,648.]])print('Theresultifx2/x1is:')print(x2/x1)print('Judgewhethera...
继续阅读 >