Python frozenset() 函数

Python 教程 · 2019-02-01 18:26:43

描述

frozenset() 返回一个冻结的集合,冻结后集合不能再添加或删除任何元素。

语法

frozenset() 函数语法:

class frozenset([iterable])

参数

  • iterable -- 可迭代的对象,比如列表、字典、元组等等。

返回值

返回新的 frozenset 对象,如果不提供任何参数,默认会生成空集合。

实例

以下实例展示了 frozenset() 的使用方法:

>>>a = frozenset(range(10)) # 生成一个新的不可变集合 >>> a frozenset([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> b = frozenset('codercto') >>> b frozenset(['b', 'r', 'u', 'o', 'n']) # 创建不可变集合 >>>

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

计算理论导论

计算理论导论

塞普斯 / 机械工业出版社 / 2002-8 / 39.0

This book——by a noted authority and educator in the field——presents computer science theory from a uniquely intuitive,“big picture”perspective.The author grounds his clear and interesting study on ......一起来看看 《计算理论导论》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器