Is the python collection a variable summary


A set is an unordered variable sequence. The elements in a collection must be hash-able, that is, immutable data types.

Empty set


Note that a={} creates an empty dictionary.

Set — Variable sets. Elements in a collection can be added or deleted dynamically.

Frozenset — an immutable set. Elements in a collection are immutable.

Note: For union, intersection, difference set, etc., the return value has the same type as the leftmost operand. For example, S & T takes intersection. S set is a set type set, t set is a frozenset type set, then the result will be set type set.

You can also use set () to convert to collections





You can also create a collection with {}




Like dictionaries, because collections are disordered, only one of them is retained when there are repetitive elements.

An immutable set is an unordered immutable set.

Create with frozenset (seq)




Elements can only be hash



It is mainly used as the key of dictionary. The difference between tuple and tuple is disorder, elements are not repeatable, and elements can only be immutable types.

Description: Other combinatorial data types can be transformed into immutable set types (or variable set types can be transformed into immutable set types frozenset), returning an immutable set with no duplicate elements and arbitrary ordering.

Frozenset () function

Syntax: frozenset () – > empty frozenset object returns an invariant empty set

Frozenset (iterable) – > frozenset object returns an immutable new collection

Iterable — The combined data type to be transformed.