Nehmen Sie die erste N -Reihe des Wörterbuchs Python

a_dictionary = {"name" : "John", "age" : 35, "height" : 65}

dict_items = a_dictionary.items()

first_two = list(dict_items)[:2]
print(first_two)

OUTPUT
[('name', 'John'), ('age', 35)]

first_three = list(dict_items)[:3]
print(first_three)

OUTPUT
[('name', 'John'), ('age', 35), ('height', 65)]
dcbert