问题引入:
同学在调试python代码的两个for循环遍历时发现输出有问题,因为遍历的有map()在,由于这个可迭代对象的出现,导致map()只能循环迭代一轮。
问题实质:
python中,map()对象,只能遍历一次,即从头遍历到尾,之后再遍历,只能得到为空的结果。
实例说明:
def scanD(D,CK,minSupport):
ssCnt = {}
s=list(CK)
pp = list(CK)
for tid in D:
print("###########")
print(tid)
print("##################")
for can in pp:
print("*******")
print(can)
print("*************")
D = [[1,3,4],[2,3,5],[1,2,3,5],[2,5]]
#CK = [[1],[2],[3],[4],[5]]
#CK = [frozenset[1],frozenset[2],frozenset[3],frozenset[4],frozenset[5]]
temp = [[1],[2],[3],[4],[5]]
def scanD(D,CK,minSupport):
ssCnt = {}
for tid in D:
print("###########")
pri