-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadJsonData.py
61 lines (49 loc) · 1.47 KB
/
loadJsonData.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import json
import copy
global aList
aList=[]
global qList
qList=[]
def fCost(minp, maxp):
global qList
fList=[]
for item in qList:
if int(item ['cost']) >=minp and int(item ['cost']) <=maxp:
fList.append(item)
qList=copy.deepcopy(fList)
def fRam(minp, maxp):
global qList
fList=[]
for item in qList:
if int(item ['mram']) >=minp*1024 and int(item ['mram']) <= maxp*1024:
fList.append(item)
qList=copy.deepcopy(fList)
def fDiag(minp, maxp):
global qList
fList=[]
for item in qList:
if float(item ['screen diagonal']) >=float(minp) and float(item['screen diagonal']) <= float(maxp):
fList.append(item)
qList=copy.deepcopy(fList)
def printJson():
global qList
str1=""
for item in qList:
# cloth=item['cloth']
str1+="\n"+"Фирма: " + item['brand'] +" \n Модель: " +item['model']+" \n Цена: "+ item['cost'] + ""\
"\n Объем RAM: " + item['ram'] + " Диагональ экрана: " + item['screen diagonal'] + ""\
"\n Описание: "+ item['description'] + "\n"
return str1
def initData():
global aList
fileObject = open ("data.json", "r", encoding="UTF-8")
jsonContent = fileObject.read()
aList = json.loads(jsonContent)
if __name__ == '__main__':
initData()
qList=copy.deepcopy(aList)
fCost(2000, 40000)
fRam(0, 6)
fDiag(2.0, 3.0)
q= printJson()
print(q)