简体   繁体   English

将双方括号变成单方括号

[英]turn double square brackets to single

How can I remove the double square brackets of a numpy array to single square brackets like a list? 如何将numpy数组的双方括号删除为列表的单个方括号?

[[0, 3.49, 0, 4.55]]

desired output 期望的输出

[0,3.49,0,4.55]

I have searched through SO looking for numpy array to list , square brackets numpy, not being able to find an answer 我已经搜索过SO寻找要列出的numpy数组,方括号numpy,却找不到答案

to_list() only add commas among the values to_list()仅在值之间添加逗号

如果它们被编码为列表,则只需使用[0]元素

Are you sure it was a numpy array? 您确定这是一个numpy数组吗?

I think just use 我认为只是使用

my_list[0] 

to get the first element (in the first element is [0,3.49,0,4.55] ) 获取第一个元素(第一个元素为[0,3.49,0,4.55]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM