1. 程式人生 > >python出現float() argument must be a string or a number, not 'map'的錯誤

python出現float() argument must be a string or a number, not 'map'的錯誤

報錯:TypeError: float() argument must be a string or a number, not 'map'

這時候,首先你肯定是用了map()這個函式,不管你用map這個函式把資料轉變成了什麼格式,不管是int還是float還是其它的,最後,你要把map完的資料轉換成list,如果你要是需要array的話,可以再轉換成array,但是要套在list外面。

簡單來說,最簡單的解決這個報錯的方法是這樣,找到你用map函式的位置,改成下面這樣;

x = list(map())