Dictionary Data type
Now I have to evaluate dictionaries in the sequences types. It is the combination of (Key, Value) pairs forms as elements in the dictionary type. We can extract each one as separate list that is keys list, values list. See my examples given in the below:
Diectionary type in Jython |
# items is list of tuples and list variables, list variables in#This script will be sample for the dictionary type
D1={}
print D1
D2={'app1':'192.168.11.129:80', 'app2':'192.168.11.130:81$
print D2
print D2['app2']
print D2.keys()
print D2.values()
print D2.items()
$variables in square brackets and tuples in round bracket$ square brackets and tuples in round brackets.
O/P
{}
{'app2': '192.168.11.130:81', 'app1': '192.168.11.129:80'}
192.168.11.130:81
['app2', 'app1']
['192.168.11.130:81', '192.168.11.129:80']
[('app2', '192.168.11.130:81'), ('app1', '192.168.11.129:80')]
No comments:
Post a Comment