Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 PyMongo,看到有人推荐使用 offind()[:]而不是find(). 很好奇有什么区别?
find()[:]
find()
[:]制作列表的浅表副本,因此对对象的引用是相同的。我查看了 Pymongo 文档,我看不出有任何理由复制find(). 我认为情况更糟,因为您必须再次遍历结果集:
[:]
>>> from timeit import timeit >>> timeit('range(100000)[:]', number=1000) 2.056607127195644 >>> timeit('range(100000)', number=1000) 1.1496167131002366
'重量转换器'
试图掌握使用存根的窍门,但我无法获得正确的格式,我有什么问题?我知道在这种情况下我已经在代码中使用了该方法,但我正在尝试学习如何正确执行存根。
测试:
describe "Convert Pounds to Kilo