0
From str to float in Python
I really want to know how to change a nested str list such as [["2.1", "3.4"], ["1.1", "5.6"]] to a nested float list like [[2.1, 3.4], [1.1, 5.6]]. If it's not nested, I think it's realized by using map(float, "str_list"), but if I want to do that to a nested list, I haven't got any nice solution. Is there anybody who has some idea? I really appreciate your comment. Thank you in advance!!
2 Antworten
+ 1
0
Thank you for your suggestion, but if the str_list is nested like [["2.1", "3.4"], ["1.1", "5.6"]], Python returns TypeError which says argument must be a sting or a number, not 'list'. Is there any solution for that?