-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4-4-1.py
More file actions
45 lines (38 loc) · 1015 Bytes
/
Copy path4-4-1.py
File metadata and controls
45 lines (38 loc) · 1015 Bytes
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
import simplejson as json
data = {}
data['people'] = []
data['people'].append({
'name': 'Kim',
'website': 'naver.com',
'from': 'Seoul',
})
data['people'].append({
'name': 'Park',
'website': 'google.com',
'from': 'Busan'
})
data['people'].append({
'name': 'Lee',
'website': 'daum.net',
'from': 'Incheon'
})
#print(data)
#{'people': [{'website': 'naver.com', 'name': 'Kim', 'from': 'Seoul'}, {'website': 'google.com', 'name': 'Park', 'from': 'Busan'}, {'website': 'daum.net', 'name': 'Lee', 'from': 'Incheon'}]}
e = json.dumps(data, indent=4)
#print(type(e))
#print(e)
d = json.loads(e)
#print(type(d))
#print(d)
with open('d:/bbb/member.json','w') as outfile:
outfile.write(e)
with open('d:/bbb/member.json','r') as infile:
r = json.loads(infile.read())
#print("="*80)
#print(type(r))
#print(r)
for p in r['people']:
print('Name: ' + p['name'])
print('Website: ' + p['website'])
print('From: ' + p['from'])
print('')