【发布时间】:2020-10-21 03:11:15
【问题描述】:
我编写了以下代码来翻转二维 numpy 数组行中的两个值。但是,我想知道是否有更好的方法来做到这一点。提前致谢
def mtn(offg):
for row in range(offg.shape[0]):
point1 = random.randint(0, 139)
point2 = random.randint(0, 139)
temp = offg[row, point1]
offg[row, point1] = offg[row, point2]
offg[row, point2] = temp
return offg
【问题讨论】: