我正在尝试循环数据库输出,并使用以下代码将每个循环的结果作为变量获取。
select
p1.pdate,
p1.status,
count(*) as total,
sum(p1.amount) as total_amount,
concat(round(( count(*)/
(select count(*) from payments p2 where p2.pdate = p1.pdate group by pdate )
* 100 ),2),'%') AS percentage
from
payments p1
group by pdate, status;
我已经尝试通过以下方式将其放入变量中:
for item in output:
v=''.join(item)
link="https://example.com/user/{}".format(v)
print(link)
但这没用
答案 0 :(得分:4)
您可能意味着您想要一个链接列表:
var = ["https://example.com/user/{}".format(''.join(item)) for item in output]