我使用浮点值列表作为高图表中系列中的数据。它不会显示,因为输出中有括号和逗号。
像这样出现:
[(0.078,), (33.93,), (33.374,)]
我需要它像这样出现:
[0.078, 33.93, 33.374]
这是用于设置系列中数据的python代码:
dbexecution = c.execute("SELECT column_name from table_name")
series = [{"name": 'cityname', "data": list(dbexecution)}]
答案 0 :(得分:2)
>>> import itertools
>>> L = [(0.078,), (33.93,), (33.374,)]
>>> list(itertools.chain.from_iterable([(0.078,), (33.93,), (33.374,)]))
[0.078, 33.93, 33.374]
答案 1 :(得分:1)
L = [(0.078,), (33.93,), (33.374,)]
L = str(L)
a = ''.join(L).replace('(','')
print(''.join(a).replace(',)',''))
输出:
[0.078, 33.93, 33.374]