我遇到了一个Python脚本:
fea_det = cv2.xfeatures2d.SIFT_create()
des_ext = cv2.xfeatures2d.SIFT_create()
des_list = []
for image_path in image_paths:
im = cv2.imread(image_path)
kpts = fea_det.detect(im)
kpts, des = des_ext.compute(im, kpts)
des_list.append((image_path, des))
我的问题与不同变量和参数的含义无关,而与我们如何理解这一说法有关:
kpts, des = des_ext.compute(im, kpts)
在kpts
和des
中会出现什么?它们的数据类型是什么?你知道吗
Comma separated identifiers on LHS of assignment statement performs iterable unpacking on result of RHS。报价文件:
它们的数据类型是什么?
我不知道也不在乎。 执行赋值时与Python相同。它可能会关心你是否要求这些对象以后做些什么。你知道吗
Python有一种称为解包的机制。这在其他语言中称为解构赋值。你知道吗
它是这样的:当表达式的计算结果是iterable对象(例如
list
或tuple
)时,可以在赋值时将内部值分散到单独的变量:解包的行为可能是
raise
和Exception
:函数get_2_tuple()
必须返回一个iterable,其中正好有两个值才能工作。你知道吗相关问题 更多 >
编程相关推荐