ValueError when checking if variable is None or numpy.array

后端 未结 3 1958
感动是毒
感动是毒 2020-12-07 17:13

I\'d like to check if variable is None or numpy.array. I\'ve implemented check_a function to do this.

def check_a(a):
    if not a:
        prin         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 17:52

    You can see if object has shape or not

    def check_array(x):
        try:
            x.shape
            return True
        except:
            return False
    

提交回复
热议问题