我有两个文件要相互比较并形成一个列表。每个文件都有自己的类。书和人。在这些中,我有不同的属性。我要比较的是:person.personalcode == book.borrowed。从这里我想要一个所有借来的书的清单。我是这样开始的:
for person in person_list:
for book in booklibrary_list:
if person.personalcode == book.borrowed:
person.books.append(book, person)
for person in person_list:
if len(person.books) > 0:
print(person.personalcode + "," + person.firstname + person.lastname + "have borrowed the following books: ")
for book in person.books:
print(book)
for person in person_list:
person.books = []
但它不起作用,我错过了什么或做错了什么?