【发布时间】:2022-01-20 22:09:07
【问题描述】:
我只想从此字典中检索“left_eye”和“right_eye”,并在不同的 python 文件中使用它们。
'keypoints': {
'left_eye': (int(keypoints[0]), int(keypoints[5])),
'right_eye': (int(keypoints[1]), int(keypoints[6])),
'nose': (int(keypoints[2]), int(keypoints[7])),
'mouth_left': (int(keypoints[3]), int(keypoints[8])),
'mouth_right': (int(keypoints[4]), int(keypoints[9])),
}
在我的其他 python 文件中,我可以使用 .items() 检索所有这些文件
def face_points():
add = find_axis().add_patch
for value, number in i ['keypoints'].items():
add(shape.Circle(
number,
color='white',
radius=1,
fill=True))
face_points()
有没有一种方法可以让我只使用“left_eye”和“right_eye”而无需编辑字典?
【问题讨论】:
-
你的意思是像
i ['keypoints']['left_eye']?
标签: python dictionary