【发布时间】:2016-10-23 15:29:01
【问题描述】:
s = {1,1,2,2,3,2,1,2,4,3,5,8}
s.add(7)
print(s)
#the output is
{1, 2, 3, 4, 5, 7, 8}.
However , for
s = {1,1,2,2,3,2,1,2,4,3,5,100}
s.add(7)
print(s)
#the output is
{1, 2, 3, 4, 100, 5, 7}.
我的问题:为什么在第一种情况下,'7'被添加到集合中,以便集合按升序排序,而在第二种情况下,它被添加到集合的末尾?
【问题讨论】:
-
“集合的结尾” > 因为集合是无序的,所以不存在集合结尾的概念。
标签: python python-3.5