diff --git a/Silocean/0017/Test.py b/Silocean/0017/Test.py new file mode 100644 index 00000000..3243f582 --- /dev/null +++ b/Silocean/0017/Test.py @@ -0,0 +1,35 @@ + +# -*-coding:utf-8-*- + +__author__ = 'Tracy' +import xlrd, re, json +import sys +reload(sys) +sys.setdefaultencoding('utf-8') + +# xlrd.Book.encoding = 'gbk' +with xlrd.open_workbook('student.xls') as file: + table = file.sheet_by_index(0) + +rows = table.nrows +cols = table.ncols + +dic = {} + +content = '\n\n\n\n' + +for row in range(rows): + stu = table.row_values(row) + list = [] + for x in range(len(stu)-1): + list.append(stu[x+1]) + # print(isinstance(stu[x+1],unicode)) # 判断是否是unicode编码 + dic[stu[0]] = list + +s = json.dumps(dic, indent=4, ensure_ascii=False) + +content = content + s + '\n\n' +with open('student.xml', 'w') as f: + f.write(content) + + diff --git a/Silocean/0017/student.xls b/Silocean/0017/student.xls new file mode 100644 index 00000000..ee6454c6 Binary files /dev/null and b/Silocean/0017/student.xls differ diff --git a/Silocean/0017/student.xml b/Silocean/0017/student.xml new file mode 100644 index 00000000..5f839b46 --- /dev/null +++ b/Silocean/0017/student.xml @@ -0,0 +1,29 @@ + + + + +{ + "1": [ + "张三", + "150", + "120", + "100" + ], + "3": [ + "王五", + "60", + "66", + "68" + ], + "2": [ + "李四", + "90", + "99", + "95" + ] +} + + \ No newline at end of file diff --git a/Silocean/0018/Test.py b/Silocean/0018/Test.py new file mode 100644 index 00000000..bb374239 --- /dev/null +++ b/Silocean/0018/Test.py @@ -0,0 +1,24 @@ +# -*-coding:utf-8-*- +__author__ = 'Tracy' + +import xlrd,json,sys +reload(sys) +sys.setdefaultencoding('utf8') + +with xlrd.open_workbook('city.xls', 'w') as f: + table = f.sheet_by_index(0) + +rows = table.nrows +cols = table.ncols +dic = {} +for row in range(rows): + dic[str(row+1)] = table.row_values(row)[1] + +s = json.dumps(dic, ensure_ascii=False, indent=4) + +content = '\n\n\n\n' + +content = content + s + '\n\n' + +with open('city.xml', 'w') as f: + f.write(content) \ No newline at end of file diff --git a/Silocean/0018/city.xls b/Silocean/0018/city.xls new file mode 100644 index 00000000..4ec0b777 Binary files /dev/null and b/Silocean/0018/city.xls differ diff --git a/Silocean/0018/city.xml b/Silocean/0018/city.xml new file mode 100644 index 00000000..30f21da1 --- /dev/null +++ b/Silocean/0018/city.xml @@ -0,0 +1,13 @@ + + + + +{ + "1": "上海", + "3": "成都", + "2": "北京" +} + + \ No newline at end of file diff --git a/Silocean/0019/Test.py b/Silocean/0019/Test.py new file mode 100644 index 00000000..9ce2bbf4 --- /dev/null +++ b/Silocean/0019/Test.py @@ -0,0 +1,26 @@ +# -*-coding:utf-8-*- +__author__ = 'Tracy' + +import xlrd,json,sys +reload(sys) +sys.setdefaultencoding('utf8') + +with xlrd.open_workbook('numbers.xls', 'w') as f: + table = f.sheet_by_index(0) + +rows = table.nrows +cols = table.ncols + +lists = [] + +for row in range(rows): + list = [] + for x in table.row_values(row): + list.append(x) + lists.append(list) +s = json.dumps(lists,ensure_ascii=False, indent=4) +content = '\n\n\n\n' +content = content + s + '\n\n' + +with open('numbers.xml', 'w') as f: + f.write(content) diff --git a/Silocean/0019/numbers.xls b/Silocean/0019/numbers.xls new file mode 100644 index 00000000..6ebca345 Binary files /dev/null and b/Silocean/0019/numbers.xls differ diff --git a/Silocean/0019/numbers.xml b/Silocean/0019/numbers.xml new file mode 100644 index 00000000..e92e06e6 --- /dev/null +++ b/Silocean/0019/numbers.xml @@ -0,0 +1,25 @@ + + + + +[ + [ + 1.0, + 82.0, + 65535.0 + ], + [ + 20.0, + 90.0, + 13.0 + ], + [ + 26.0, + 809.0, + 1024.0 + ] +] + + \ No newline at end of file