Python3.6 map() function

1. The use of the map() function in Python 3.6 is different from that in 2.7. When calculating the length len(), you will get the following error

D=map(set,dataSet)
numItems = float ( len (D))

Using the map() function in Python 3.6 is different from that in 2.7. When calculating the length len(), you will get the following error:

TypeError: object of type 'map' has no len()


Solution: To get the same effect, add a list()


D=list(map(set,dataSet))
numItems = float ( len (D))

Guess you like

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