Skip to content

Commit fec13a1

Browse files
committed
Create CreateTestJsonData.py
1 parent 61d5cd8 commit fec13a1

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/python
2+
# -*- coding: UTF-8 -*-
3+
import os
4+
import json
5+
6+
class Item:
7+
object_id=0
8+
object_name=""
9+
object_icon=""
10+
color=0
11+
object_type=0
12+
object_rank=0
13+
profession=0
14+
stacklimit=0
15+
usedlevel=0
16+
sellid=0
17+
sellgold=0
18+
auction=0
19+
use_type=0
20+
result=0
21+
describe=""
22+
buynumber=0
23+
price=0
24+
time=0
25+
usenumber=0
26+
shortcut=0
27+
28+
def toDic(self):
29+
return self.__dict__
30+
31+
def CreateNormalKeyValueJson():
32+
tmpDic={}
33+
for index in range(100000):
34+
tmpItem=Item()
35+
tmpItem.object_id=index
36+
tmpItem.object_name="name"+str(index)
37+
tmpItem.object_icon="icon"+str(index)
38+
tmpItem.color=index
39+
tmpItem.object_type=index
40+
tmpItem.object_rank=index
41+
tmpItem.profession=index
42+
tmpItem.stacklimit=index
43+
tmpItem.usedlevel=index
44+
tmpItem.sellid=index
45+
tmpItem.sellgold=index
46+
tmpItem.auction=index
47+
tmpItem.use_type=index
48+
tmpItem.result=index
49+
tmpItem.describe="describe"+str(index)
50+
tmpItem.buynumber=index
51+
tmpItem.price=index
52+
tmpItem.time=index
53+
tmpItem.usenumber=index
54+
tmpItem.shortcut=index
55+
tmpDic[index]=tmpItem.toDic()
56+
57+
tmpJson=json.dumps(tmpDic)
58+
59+
# 写文件
60+
with open(os.getcwd()+"/test_normal.json", "wt") as out_file:
61+
out_file.write(tmpJson)
62+
out_file.close()
63+
64+
def CreateArrayJson():
65+
tmpDic={}
66+
67+
tmpValues=[]
68+
for index in range(100000):
69+
tmpItem=Item()
70+
tmpItem.object_id=index
71+
tmpItem.object_name="name"+str(index)
72+
tmpItem.object_icon="icon"+str(index)
73+
tmpItem.color=index
74+
tmpItem.object_type=index
75+
tmpItem.object_rank=index
76+
tmpItem.profession=index
77+
tmpItem.stacklimit=index
78+
tmpItem.usedlevel=index
79+
tmpItem.sellid=index
80+
tmpItem.sellgold=index
81+
tmpItem.auction=index
82+
tmpItem.use_type=index
83+
tmpItem.result=index
84+
tmpItem.describe="describe"+str(index)
85+
tmpItem.buynumber=index
86+
tmpItem.price=index
87+
tmpItem.time=index
88+
tmpItem.usenumber=index
89+
tmpItem.shortcut=index
90+
tmpItemDic={}
91+
tmpItemDic=tmpItem.toDic()
92+
tmpValues.append(list(tmpItemDic.values()))
93+
94+
if index==0:
95+
tmpKeyList=list(tmpItemDic.keys())
96+
tmpKeyDic={}
97+
for tmpKeyIndex in range(len(tmpKeyList)):
98+
tmpKey=tmpKeyList[tmpKeyIndex]
99+
tmpKeyDic[tmpKey]=tmpKeyIndex
100+
tmpDic["key"]=tmpKeyDic
101+
102+
tmpDic["value"]=tmpValues
103+
tmpJson=json.dumps(tmpDic)
104+
105+
# 写文件
106+
with open(os.getcwd()+"/test_array.json", "wt") as out_file:
107+
out_file.write(tmpJson)
108+
out_file.close()
109+
110+
111+
#使用python 库 求MD5
112+
def run():
113+
CreateArrayJson()
114+
115+
116+
if __name__=="__main__":
117+
run()

0 commit comments

Comments
 (0)