我遇到一些难以解决的问题

如何编写仅在4x5矩阵中选择圆的函数

       .    .   .   .   .
       .    o   o   o   .
       .    o   o   o   .
       .    .   .   .   .

import numpy as np  
def list_3(arr):
    return

下面的代码用于测试 如果它没有给出任何错误,则代码有效

def list_3_test():
arr = np.array([[ 1.,2.,3.,4.,5.],[ 0.,1.,4.],[-1.,0.,3.],[-2.,-1.,2.]])
correct = np.array([[1.,[0.,2.]])
your_solution = list_3 (arr)
assert np.array_equal(your_solution,correct)
list_3_test()
lwb896148823 回答:我遇到一些难以解决的问题

尝试此代码

def list_3(arr):
    return arr[1:-1,1:-1]
本文链接:https://www.f2er.com/3155977.html

大家都在问