赞
踩
setA = set('Hello, World!')
setA.remove("X")
help(set.remove)
Traceback (most recent call last):
File “<pyshell#29>”, line 2, in
setA.remove(“x”)
KeyError: ‘x’
Help on method_descriptor:
remove(…)
Remove an element from a set; it must be a member.
If the element is not a member, raise a KeyError.
集合元素不存在,提示错误(KeyError)
setA = set('Hello, World!')
setA.discard("X")
help(set.discard)
无错误信息输出
Help on method_descriptor:
discard(…)
Remove an element from a set if it is a member.
If the element is not a member, do nothing.集合元素不存在,不显示任何信息
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。