<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
There is a file named analyse.py in the
D:\Python34\Lib\site-packages.<br>
<br>
<br>
import sqlite3,os,jinja2<br>
db = r'F:\workspace\china\data\china.sqlite'<br>
con = sqlite3.connect(db)<br>
cur = con.cursor()<br>
<br>
class status():<br>
def grow(self):<br>
self.res=cur.execute('select 代码,所属行业,注册资本,雇员人数,管理人员人数 from
profile limit 10').fetchall()<br>
<br>
def display(self):<br>
template = jinja2.Template('''<br>
<table border=1><br>
{% for row in res %}<br>
<tr><br>
{% for col in row -%}<br>
<td>{{ col}}</td><br>
{% endfor %}<br>
</tr><br>
{% endfor %}<br>
</table><br>
''')<br>
with open('f:\\test.html', 'w') as f:<br>
f.write(template.render(res=self.res))<br>
import webbrowser<br>
webbrowser.open('f:\\test.html')<br>
<br>
<br>
when i open python3.4 console to input the code: <br>
import analyse<br>
x=analyse.status()<br>
x.grow()<br>
x.display()<br>
<br>
i get <br>
<img src="cid:part1.00080407.07060500@gmail.com" alt=""><br>
<br>
when i add return(self.res) in grow method to make analyse.py into
the following:<br>
<br>
import sqlite3,os,jinja2<br>
db = r'F:\workspace\china\data\china.sqlite'<br>
con = sqlite3.connect(db)<br>
cur = con.cursor()<br>
<br>
class status():<br>
def grow(self):<br>
self.res=cur.execute('select 代码,所属行业,注册资本,雇员人数,管理人员人数 from
profile limit 10').fetchall()<br>
return(self.res)<br>
def display(self):<br>
template = jinja2.Template('''<br>
<table border=1><br>
{% for row in res %}<br>
<tr><br>
{% for col in row -%}<br>
<td>{{ col}}</td><br>
{% endfor %}<br>
</tr><br>
{% endfor %}<br>
</table><br>
''')<br>
with open('f:\\test.html', 'w') as f:<br>
f.write(template.render(res=self.res))<br>
import webbrowser<br>
webbrowser.open('f:\\test.html')<br>
<br>
<br>
now again input the code:<br>
import analyse<br>
x=analyse.status()<br>
x.grow() <br>
the x.grow() will output <br>
<br>
[('600000', '银行', '187亿', 39340.0, 30.0), <br>
('600004', '民航机场', '11.5亿', 4499.0, 23.0),<br>
('600005', '钢铁行业', '101亿', 38857.0, 24.0), <br>
('600006', '汽车行业', '20.0亿', 10290.0, 20.0), <br>
('600007', '房地产', '10.1亿', 2332.0, 19.0),<br>
('600008', '公用事业', '22.0亿', 6515.0, 20.0), <br>
('600009', '民航机场', '19.3亿', 5472.0, 18.0), <br>
('600010', '钢铁行业', '80.0亿', 31389.0, 19.0),<br>
('600011', '电力行业', '141亿', 37729.0, 29.0), <br>
('600012', '高速公路', '16.6亿', 2106.0, 14.0)]<br>
<br>
now what i want to do is :<br>
1.keep return(self.res) in grow method.<br>
2.it is my target that when run the code: <br>
<br>
import analyse<br>
x=analyse.status()<br>
x.grow()<br>
<br>
there is nothing output in my console , to make return(self.res)
not to output the content of list ,<br>
how can i do ? <br>
</body>
</html>