小编Ash*_*and的帖子

为什么由不同初始化集合构造的元组相等?

我期待以下两个元组

>>> x = tuple(set([1, "a", "b", "c", "z", "f"]))
>>> y = tuple(set(["a", "b", "c", "z", "f", 1]))
Run Code Online (Sandbox Code Playgroud)

比较不平等,但他们不:

>>> x == y
>>> True
Run Code Online (Sandbox Code Playgroud)

这是为什么?

python comparison tuples hashtable set

38
推荐指数
4
解决办法
2527
查看次数

标签 统计

comparison ×1

hashtable ×1

python ×1

set ×1

tuples ×1