Python frozenset() 函数

Python 3 教程 · 2019-02-05 10:44:22

描述

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 3 教程 文章: https://www.codercto.com/courses/l/10.html

查看所有标签

Thirty-three Miniatures

Thirty-three Miniatures

Jiří Matoušek / American Mathematical Socity / 2010-6-18 / USD 24.60

This volume contains a collection of clever mathematical applications of linear algebra, mainly in combinatorics, geometry, and algorithms. Each chapter covers a single main result with motivation and......一起来看看 《Thirty-three Miniatures》 这本书的介绍吧!

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

各进制数互转换器

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

HTML 编码/解码

MD5 加密
MD5 加密

MD5 加密工具