Python 如何将输出格式化为表
下面是对数据库进行查询的python代码Python 如何将输出格式化为表,python,mysql,Python,Mysql,下面是对数据库进行查询的python代码 cursor.execute("""select count(distinct offering_name) as events ,count(learner) as learners ,count(distinct learner) as unique_learner ,count(dropped) as dropped ,sum(trans_price) as trans_price from EMS_dat
cursor.execute("""select count(distinct offering_name) as events
,count(learner) as learners
,count(distinct learner) as unique_learner
,count(dropped) as dropped
,sum(trans_price) as trans_price
from EMS_data where organization like 'eng%' and manager ='rakesh'""")
#result= cursor.fetchall()
for result in cursor:
print result
结果是这样的
(367L, 7200L, 4543L, 7200L, 3216157.0)
但是我想喜欢这个
(367L, 7200L, 4543L, 7200L, 3216157.0)
+--------+----------+----------------+---------+--------------------+
|活动|学习者|独特|学习者|下降|交易价格|
+--------+----------+----------------+---------+--------------------+
| 378 | 8092 | 5204 | 8092 | 3197704.0799999996 |
+--------+----------+----------------+---------+--------------------+
你怎么能这样做。。。请帮助我,我不明白你的问题,怎么了?输出格式?这是一个示例,您可以使用括号
[]
访问它们,并在其中放置索引,从0开始
打印结果[0]#打印367
然后你可以自己格式化它。看看这个