0

我在下面的代码中收到以下错误:

TypeError:GetSize() 缺少 1 个必需的位置参数:'self'

import PySpin

system = PySpin.System.GetInstance()
cam_list = system.GetCameras()

# This works:

numCams  = cam_list.GetSize()

# this fails:

numCams  = PySpin.CameraList.GetSize()

print ("No. of cams: ", numCams)

为什么?

编辑:

class myMain(object):
    def main(self):
        numCams  = PySpin.CameraList.GetSize()
        print ("No. of cams: ", numCams)
4

1 回答 1

1

在调用它之前尝试初始化它

cams = PySpin.CameraList()
numCams = cams.GetSize()
print ("No. of cams: ", numCams)
于 2019-05-30T14:40:40.977 回答