简体   繁体   English

像dict这样的Python数据结构

[英]Python data structure like dict

Online I found some code that used the variable explored . 在网上我找到了一些使用所explored变量的代码。 This variable is implemented like a dictionary: explored = {rootId} , but it doesn't have key-value association, moreover this variabile uses the function .add(elem) while the dict doesn't have this function. 该变量的实现方式类似于字典: explored = {rootId} ,但它没有键值关联,而且此变量使用.add(elem)函数,而dict没有此功能。 eg. 例如。 explored.add(elem) . explored.add(elem)

Which data structure is that? 那是哪种数据结构? (I'm using python 3.6.3) (我正在使用python 3.6.3)

可能是一个集合,它具有方法“ add”,但是您可以简单地打印类型,例如:

print(type(explored))

It's a set . 这是一个set There are also online examples that use the methods you mentioned. 也有使用您提到的方法的在线示例

Next time you wonder, I suggest you just print the type, like this: 下次您想知道时,建议您仅打印类型,如下所示:

print(type(explored));

It's the set datastructure. 这是set结构。 Here's a link to it on the official docs: https://docs.python.org/3/tutorial/datastructures.html#sets 这是官方文档上的链接: https : //docs.python.org/3/tutorial/datastructures.html#sets

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM