TypeError: GetSize() missing 1 required positional argument: 'self'

TypeError: GetSize() missing 1 required positional argument: 'self'

我在使用以下代码时遇到以下错误:

TypeError: GetSize() missing 1 required positional argument: '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)

尝试在调用之前对其进行初始化

cams = PySpin.CameraList()
numCams = cams.GetSize()
print ("No. of cams: ", numCams)