如何mat匹配两个字典键值

时间:2017-01-27 10:34:11

标签: python dictionary

我有一个循环,它应该在第一个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

但我想比较两个词典键值。

0 个答案:

没有答案