Python Set issuperset() 方法

Python 3 教程 · 2019-02-06 20:14:13

描述

issuperset() 方法用于判断指定集合的所有元素是否都包含在原始的集合中,如果是则返回 True,否则返回 False。

语法

issuperset() 方法语法:

set.issuperset(set)

参数

  • set -- 必需,要比查找的集合

返回值

返回布尔值,如果都包含返回 True,否则返回 False。

实例

判断集合 y 的所有元素是否都包含在集合 x 中:

实例 1

x = {"f", "e", "d", "c", "b", "a"} y = {"a", "b", "c"} z = x.issuperset(y) print(z)

输出结果为:

True

如果没有全部包含返回 False:

实例 1

x = {"f", "e", "d", "c", "b"} y = {"a", "b", "c"} z = x.issuperset(y) print(z)

输出结果为:

False

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

查看所有标签

Types and Programming Languages

Types and Programming Languages

Benjamin C. Pierce / The MIT Press / 2002-2-1 / USD 95.00

A type system is a syntactic method for automatically checking the absence of certain erroneous behaviors by classifying program phrases according to the kinds of values they compute. The study of typ......一起来看看 《Types and Programming Languages》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

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

HTML 编码/解码