python中使用matrix函数实现矩阵翻转,具体方法如下:
1.矩阵上下翻转
for i in range(row // 2):matrix[i], matrix[row-1-i] = matrix[row-1-i], matrix[i]
for i in range(row // 2):
matrix[i], matrix[row-1-i] = matrix[row-1-i], matrix[i]
2.矩阵左右翻转
for m in matrix:for j in range(col // 2):m[j], m[col-1-j] = m[col-1-j], m[j]
for m in matrix:
for j in range(col // 2):
m[j], m[col-1-j] = m[col-1-j], m[j]