我有一个循环,它应该在第一个if上触发,但它没有。
如果我打印值
print("Books: {0} {1} {2} {3}".format(book['bookid'], allbooks['bookid'], book['Author'], allbooks['Author']))
我得到: 书籍:0001 0001 AJHartley AJHartley
我试过了:
if book['bookid'] in allbooks['bookid'] and book['Author'] in allbooks['Author']:
book_exists += 1
if book['bookid'] == allbooks['bookid'] and book['Author'] == allbooks['Author']:
book_exists += 1
我能获得比赛的唯一方法就是
if "0001" in book['bookid'] and "AJHartley" in allbooks['Author']:
book_exists += 1
但我想比较两个词典键值。