-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (38 loc) · 993 Bytes
/
test.py
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
import json
from pprint import pprint
# Opening JSON file
try:
file = open('setting.json', encoding="utf8")
except Exception as e:
print(e)
# returns JSON object as
# a dictionary
data = json.load(file)
pprint(data)
print(data["MORE_TAKASHIM"])
print(data["colors"]["BLACK1"])
# Iterating through the json
# list
# print(data["name"])
# sheet = 'SERVERS'
#
# pprint(data[sheet])
# for server in data[sheet]:
# for device in server["devices"]:
# pprint(device)
# for key in data[sheet]:
# name = key["name"]
# for device in key["devices"]:
# print(name)
# pprint(device)
# print('\n')
# print(device["hostname"])
# for key in data[sheet]:
# print(key)
# # print(key["name"])
# print(key["devices"][0])
# # print(key["devices"][0]['ip'])
# people = {"david": {'name': 'John', 'age': '27', 'sex': 'Male'},
# 2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}}
#
# print(people["david"]['name'])