在html上使用时,数组内容格式错误

问题描述 投票:0回答:1

我有以下循环:

for elem in Data.objects.filter(user=id):
                variables['labels'].append(time.strftime("%H%M%S", time.localtime(elem.timestamp)))

这会产生以下结果:

['000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000']

但是当我检查html时,这是结果:

labels: ['000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000']

为什么会这样?

python html arrays django dictionary
1个回答
0
投票

我用以下过滤器解决了它:

{{ data.labels|safe }}
© www.soinside.com 2019 - 2024. All rights reserved.