在使用Python进行矩阵操作时,当内部含有除法时,会产生错误:

TypeError: slice indices must be integers or None or have an __index__ method

例如:

 

img=np.hstack((a[:,0:100/2],b[:,100/2,:])) 

由于除法/自动产生的类型是浮点型,因此出现上述错误,修正方法为,将/更改为//

代码为:

 

img=np.hstack((a[:,0:100//2],b[:,100//2,:])) 

相关文章:

  • 2021-11-07
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2021-12-24
  • 2021-10-26
  • 2021-09-03
  • 2022-12-23
相关资源
相似解决方案