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://www.codercto.com/courses/l/8.html

查看所有标签

Graph Algorithms

Graph Algorithms

Shimon Even / Cambridge University Press / 2011-9-19 / USD 32.99

Shimon Even's Graph Algorithms, published in 1979, was a seminal introductory book on algorithms read by everyone engaged in the field. This thoroughly revised second edition, with a foreword by Richa......一起来看看 《Graph Algorithms》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码