Python Set pop() 方法

Python 3 教程 · 2019-02-06 20:27:39

描述

pop() 方法用于随机移除一个元素。

语法

pop() 方法语法:

set.pop()

参数

返回值

返回移除的元素。

实例

随机移除一个元素:

实例 1

fruits = {"apple", "banana", "cherry"} fruits.pop() print(fruits)

输出结果为:

{'apple', 'banana'}

输出返回值:

实例 1

fruits = {"apple", "banana", "cherry"} x = fruits.pop() print(x)

输出结果为:

banana

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

查看所有标签

The Cult of the Amateur

The Cult of the Amateur

Andrew Keen / Crown Business / 2007-6-5 / USD 22.95

Amateur hour has arrived, and the audience is running the show In a hard-hitting and provocative polemic, Silicon Valley insider and pundit Andrew Keen exposes the grave consequences of today’s......一起来看看 《The Cult of the Amateur》 这本书的介绍吧!

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

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具