你能帮我吗? 我的代码不起作用:
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
我该怎么做?你知道吗
这里,变量称为
my_pictures
:您正在尝试访问
my_picture
:假设你写了
my_pictures = my_pictures, new2
这将生成一个元组,其中第一个元素是旧元组,第二个元素是new2
:(ab, bb), new2
但如果要创建一个包含三个元素的元组,可以执行以下操作:
my_pictures = (*my_pictures, new2)
。你知道吗相关问题 更多 >
编程相关推荐