python添加numpy.数组到tup

2024-04-24 20:50:37 发布

您现在位置:Python中文网/ 问答频道 /正文

你能帮我吗? 我的代码不起作用:

import face_recognition
a = face_recognition.load_image_file('image.jpg')     # my picture 1
ab = face_recognition.face_encodings(a)[0]            # type numpy.array

b = face_recognition.load_image_file('image.jpg')     # my picture 2
bb = face_recognition.face_encodings(b)[0]            # type numpy.array


new = face_recognition.load_image_file('image.jpg')    # my picture 3
new2 = face_recognition.face_encodings(new)[0]         # type numpy.array

my_pictures = ab, bb   # type tuple

但这不起作用:

my_pictures = my_picture, new2    # i want to add the new face data to the others

我该怎么做?你知道吗


Tags: imagenumpynewabmytypeloadarray
1条回答
网友
1楼 · 发布于 2024-04-24 20:50:37

这里,变量称为my_pictures

my_pictures = ab, bb

您正在尝试访问my_picture

my_picture = my_picture, new2 

假设你写了my_pictures = my_pictures, new2 这将生成一个元组,其中第一个元素是旧元组,第二个元素是new2(ab, bb), new2

但如果要创建一个包含三个元素的元组,可以执行以下操作: my_pictures = (*my_pictures, new2)。你知道吗

相关问题 更多 >