简体   繁体   中英

Python data structure like dict

Online I found some code that used the variable 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. eg. explored.add(elem) .

Which data structure is that? (I'm using python 3.6.3)

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

print(type(explored))

It's a 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. Here's a link to it on the official docs: https://docs.python.org/3/tutorial/datastructures.html#sets

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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