删除列表中的括号和逗号 [英] Removing brackets and comma's in list

查看:60
本文介绍了删除列表中的括号和逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用浮点值列表作为高图系列中的数据.由于输出中包含方括号和逗号,因此不会显示.

I am using a list of float values as the data in a series in high charts. It will not show up because there are brackets and commas in the output.

这样显示:

[(0.078,), (33.93,), (33.374,)]

我需要它显示如下:

[0.078, 33.93, 33.374]

这是设置系列数据的python代码:

This is the python code to set the data in the series:

dbexecution = c.execute("SELECT column_name from table_name")
series = [{"name": 'cityname', "data": list(dbexecution)}]

推荐答案

>>> 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]

这篇关于删除列表中的括号和逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆