-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhtml_outputer.py
More file actions
33 lines (28 loc) · 828 Bytes
/
html_outputer.py
File metadata and controls
33 lines (28 loc) · 828 Bytes
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
#! /usr/bin/env python
#_*_coding:utf-8_*_
class HtmlOutputer(object):
def __init__(self):
self.datas = []
def collect_data(self,data):
if data is None:
return
self.datas.append(data)
def output_html(self):
with open('output.html','w') as fout:
fout.write("<html>")
fout.write("<body>")
fout.write("<table>")
fout.write("<td>name</td>")
fout.write("<td>score</td>")
fout.write("<td>year</td>")
fout.write("<td>url</td>")
for data in self.datas:
fout.write("<tr>")
fout.write("<td>%s</td>" % data['name'])
fout.write("<td>%s</td>" % data['score'])
fout.write("<td>%s</td>" % data['year'])
fout.write("<td>%s</td>" % data['url'])
fout.write("</tr>")
fout.write("</table>")
fout.write("</body>")
fout.write("</html>")