Skip to content

Commit 8483868

Browse files
committed
Create 0015.py
1 parent a04a259 commit 8483868

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Liez-python-code/0015/0015.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import re
2+
import xlwt
3+
4+
def read2xls(x):
5+
datatable = xlwt.Workbook(encoding = 'utf-8', style_compression = 0)
6+
newsheet = datatable.add_sheet('student', cell_overwrite_ok = True)
7+
num = 0
8+
with open(x, 'r') as f:
9+
text = f.read()
10+
info = re.compile(r'"(\d+)" : "(.*?)"')
11+
for x in info.findall(text):
12+
for i in range(len(x)):
13+
newsheet.write(num, i, x[i])
14+
num += 1
15+
16+
datatable.save('liez.xls')
17+
18+
read2xls('student.txt')

0 commit comments

Comments
 (0)