我在Python/PyMongo中有奇怪的行为.
dbh = self.__connection__['test']
first = dbh['test_1']
second = dbh['test_2']
first_collection_records=first.find()
second_collection_records=second.find()
index_f=first_collection_records.count() //20
index_s=second_collection_records.count() //120
i=0
for f in first_collection_records:
for s in second_collection_records:
i=i+1
print i
Run Code Online (Sandbox Code Playgroud)
它只打印120次(1..120)而不是20x120次.有人能告诉我为什么它不会迭代外部集合?我打印结果,它总是只取第一个外部并迭代内部集合.(我发布了我在代码20和120中获得的计数,我尝试使用xrange并通过索引获取但没有任何内容)