Use frozenset as a pair in python

后端 未结 4 605
轮回少年
轮回少年 2021-02-06 06:37

I would like to make a pair of two elements. I don\'t care about the order of the elements, so I use frozenset.

I can think of the following two methods t

4条回答
  •  深忆病人
    2021-02-06 06:56

    If it is just two elements you are de-sequence them. But I am not sure, what you are trying to do here with the frozenset

    >>> s = frozenset([1,2])
    >>> s
    frozenset({1, 2})
    >>> x,y = s
    >>> x
    1
    >>> y
    2
    

提交回复
热议问题