Convert string list to numeric type in python

After a long time of trial and error, I came to know the difference between python2.X and python3.X,

The principle is to use the map function, but the information returned by the two is different

Python2.x, you can use the map function

list=[] # empty list

1
list = map ( int , list) 或者 list= map(float, list)

If it is 3.x, map returns a map object, which of course can also be converted to List:

1
list = list ( map ( float , list))

So here needs to be treated differently;


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325648453&siteId=291194637