小白教程
所有教程
关于
Search
172.70.100.192
172.70.100.192
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python func set”的源代码
本页内容
上一节:
Python_func_memoryview
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:set()}}[[Category:python3 built in functions|68]] = Python set() 函数 = [[python built in functions|Python 内置函数]] == 描述 == '''set()''' 函数创建一个无序不重复元素集,可进行关系测试,删除重复数据,还可以计算交集、差集、并集等。 == 语法 == set 语法: <sample title="" desc="" lang="python" hererun="1"> class set([iterable]) </sample> 参数说明: * iterable -- 可迭代对象对象; == 返回值 == 返回新的集合对象。 以下实例展示了 set 的使用方法: <sample title="" desc="" lang="python" hererun="1"> >>>x = set('xiaobai') >>> y = set('google') >>> x, y (set(['b', 'r', 'u', 'o', 'n']), set(['e', 'o', 'g', 'l'])) # 重复的被删除 >>> x & y # 交集 set(['o']) >>> x | y # 并集 set(['b', 'e', 'g', 'l', 'o', 'n', 'r', 'u']) >>> x - y # 差集 set(['r', 'b', 'u', 'n']) >>> </sample> [[python built in functions|Python 内置函数]]
返回至“
Python func set
”。
上一节:
Python_func_memoryview