“Map” a nested list in Python

后端 未结 4 901
自闭症患者
自闭症患者 2021-02-14 05:07

In Python, I am trying to apply an operator to a two layer nested array. For example,

a = [[\'2.3\',\'.2\'],[\'-6.3\',\'0.9\']]
for j in range(2)
    for i in r         


        
4条回答
  •  醉酒成梦
    2021-02-14 05:32

    The first argument requires a function, and as such, you can utilize the lambda operator to map float to the sub-lists. This is an example:

    a = map(lambda b : map(float, b), a)
    

提交回复
热议问题