在 Python 中与集合相交最有效的方法是什么?
我是Python新手,如果有什么问题请见谅。
我想将几个包含大量元素的集合(20 或 30)相交。
我一直在阅读并知道集合类似于哈希表(具有相同的原理)。 Sets 有 intersect 方法,我一直在尝试并且工作得很好。
不过,想请教一下有经验的人。
你会怎么办?
问题又来了。 20或30个集合(可以设置,元素不重复)并且想要对它们进行交集。不要思考集合是如何创建的(即插入并不重要)
非常感谢!
I'm new in python, sorry if there's anything wrong.
I'd like to intersect several collections (20 o 30) with a big amount of elements in them.
I've been reading and know that Sets are similar to hashtables (work with the same principle).
Sets has the intersect method, i've been trying it and works really fine.
But, would like to have an experienced opinion.
What would you do?
The problem again. 20 or 30 collections (can be set, the elements are not repeated) and want to make intersection of them. Don't think how the collections are created (i.e. the insertion doesn't matters)
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://docs.python.org/library/stdtypes.html
http://docs.python.org/library/stdtypes.html