Skip to content

Commit b4c6a15

Browse files
committed
add
1 parent 084fb56 commit b4c6a15

6 files changed

Lines changed: 68 additions & 0 deletions

File tree

‎llluiop/0015/city.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
3+
import xlwt
4+
import json
5+
6+
7+
def load_data(filepath):
8+
f = open(filepath, "r")
9+
return json.load(f)
10+
11+
def write_data_to_xls(data):
12+
xls = xlwt.Workbook()
13+
sheet = xls.add_sheet("city")
14+
15+
print data
16+
for i in range(len(data)):
17+
sheet.write(i, 0, i+1)
18+
json_data = data[str(i+1)]
19+
sheet.write(i, 1, json_data)
20+
21+
xls.save('city.xls')
22+
23+
24+
if __name__ == '__main__':
25+
data = load_data("city.txt")
26+
write_data_to_xls(data)
27+
28+
29+
30+

‎llluiop/0015/city.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"1" : "上海",
3+
"2" : "北京",
4+
"3" : "成都"
5+
}

‎llluiop/0015/city.xls‎

5.5 KB
Binary file not shown.

‎llluiop/0016/number.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
import xlwt
4+
import json
5+
6+
7+
def load_data(filepath):
8+
f = open(filepath, "r")
9+
return json.load(f)
10+
11+
def write_data_to_xls(data):
12+
xls = xlwt.Workbook()
13+
sheet = xls.add_sheet("number")
14+
15+
for i in range(len(data)):
16+
for j in range(len(data[i])):
17+
sheet.write(i, j, data[i][j])
18+
19+
xls.save('number.xls')
20+
21+
22+
if __name__ == '__main__':
23+
data = load_data("number.txt")
24+
write_data_to_xls(data)
25+
26+
27+
28+

‎llluiop/0016/number.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
[1,82,65535],
3+
[20,90,13],
4+
[26,809,1024]
5+
]

‎llluiop/0016/number.xls‎

5.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)