集合的pop,remove为什么出错

pop()用于返回集合中 的元素,remove用来移除元素
现在试试:

s={1,2,3}
s.pop()


结果为1
但使用remove()时出错:

s.remove(2)
Traceback (most recent call last):
  File "<pyshell#25>", line 1, in <module>
    s.remove(2)
KeyError: 2

报错原因是2不在集合中
那么让我们看看s

s={1,2,3}
>>> s.pop()
1
>>> s
{2, 3}

集合中有2这个元素,那么是哪里出错了?

s=[1,2,3]
试试看方括号

看这个是没什么问题,你能把你pop跟remove所有的代码贴出来吗,你分开这样子不好判断。