Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python问题中的集合_Python_Set - Fatal编程技术网

python问题中的集合

python问题中的集合,python,set,Python,Set,我们可以从集合中删除一个条目吗 它使用什么命令 比如,我的设定值是6,5,6,7,7,9…我需要删除第二个条目…我该怎么办 my_set.remove((6, 7)) remove方法可用于从集合中删除项。如果您有这些元组的列表,可以按如下方式将其清除: l = [(1,2),(3,4),(5,6)] [(1, 2), (3, 4), (5, 6)] l.remove((3,4)) [(1, 2), (5, 6)] 您可以使用: a-=集合[6,7] :-有答案。为什么要在这里提问?我知道

我们可以从集合中删除一个条目吗

它使用什么命令

比如,我的设定值是6,5,6,7,7,9…我需要删除第二个条目…我该怎么办

my_set.remove((6, 7))

remove方法可用于从集合中删除项。

如果您有这些元组的列表,可以按如下方式将其清除:

l = [(1,2),(3,4),(5,6)]

[(1, 2), (3, 4), (5, 6)]
l.remove((3,4))
[(1, 2), (5, 6)]
您可以使用:

a-=集合[6,7]


:-

有答案。为什么要在这里提问?我知道这很没品味,但11天内有16个问题?你不能自己解决问题吗?快速浏览一下官方python文档就可以找到答案。
>>> s = set([1, 2, 3])
>>> s.remove(2)
>>> s
set([1, 3])