-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary
More file actions
51 lines (43 loc) · 1.27 KB
/
dictionary
File metadata and controls
51 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
a1 = [{
'jdbc_1': {
'b_records': 'N',
'abcd': 'Y',
'MNB': 'N',
'OST': 'N'}
}]
for i in a1:
for key,val in i.items():
print(val)
print(val.get('b_records'))
========== RESTART: C:/Users/mouni/OneDrive/Desktop/listprocessing.py ==========
{'b_records': 'N', 'abcd': 'Y', 'MNB': 'N', 'OST': 'N'}
N
#use i.items() returns a view of its (key, value) pairs in dictionary
a1 = [{
'jdbc_1': {
'b_records': 'N',
'abcd': 'Y',
'MNB': 'N',
'OST': 'N'},
'jdbc_2': {
'c_records': 'N',
'abcde': 'Y',
'MNBe': 'N',
'BST': 'N'}
}]
for key,item in enumerate(a1):
keys1= list(item.keys())
print('keys.....1',keys1)
print('kyes2.....',key)
for j,k in enumerate(keys1):
print('only keys with in outer dictionary.....2',k)
print('get values .....',item[k])
print('only keys....',list(item[k].keys()))
keys.....1 ['jdbc_1', 'jdbc_2']
kyes2..... 0
only keys with in outer dictionary.....2 jdbc_1
get values ..... {'b_records': 'N', 'abcd': 'Y', 'MNB': 'N', 'OST': 'N'}
only keys.... ['b_records', 'abcd', 'MNB', 'OST']
only keys with in outer dictionary.....2 jdbc_2
get values ..... {'c_records': 'N', 'abcde': 'Y', 'MNBe': 'N', 'BST': 'N'}
only keys.... ['c_records', 'abcde', 'MNBe', 'BST']