1 ответ
+ 7
If you have a dictionary named d, it goes likes this:
d = {"key1": "string1", "key2": "string2", "key3": "string3"}
# key iteration
for k in d.keys():
print(k)
>>>
key3
key2
key1
# value iteration
for v in d.values():
print(v)
>>>
string3
string2
string1
# key-value pair iteration
for k, v in d.items():
print(k, v)
>>>
key3 string3
key2 string2
key1 string1