在重定向烧瓶中将数组/列表作为参数传递

时间:2021-07-23 15:59:43

标签: python list flask redirect

我试图在 Flask 的重定向函数中将列表作为参数传递。我的列表是这样的列表:

data_list = [['Hollis Thompson', 'Philadelphia 76ers', 31.0, 'SG', 25.0, '6-8', 206.0, 'Georgetown', 947276.0],
['Christian Wood', 'Philadelphia 76ers', 35.0, 'PF', 20.0, '6-11', 220.0, 'UNLV', 525093.0], 
['Bruno Caboclo', 'Toronto Raptors', 20.0, 'SF', 20.0, '6-9', 205.0, nan, 1524000.0], 
['DeMarre Carroll', 'Toronto Raptors', 5.0, 'SF', 29.0, '6-8', 212.0, 'Missouri', 13600000.0]]

当我在重定向中将其作为参数传递时:

return redirect(url_for("data_page", list=data_list))

在我的 data_page 中,我检索数据并将其打印出来:

data = request.args['list']
print("data:", data)

但我得到的只是带有输出的列表的第一个元素:

data: ['Hollis Thompson', 'Philadelphia 76ers', 31.0, 'SG', 25.0, '6-8', 206.0, 'Georgetown', 947276.0]

这是为什么?我确实想要整个列表而不仅仅是第一个元素..我能做什么?谢谢!

0 个答案:

没有答案