Python3 集合 clear()方法

2021-10-22 15:41 更新

Python3 列表 Python 集合

描述

clear() 方法用于移除集合中的所有元素。

語法

clear()方法語法:

set.clear()

參數(shù)

  • 無。

返回值

實例

移除 fruits 集合中的所有元素:

實例 1

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

輸出結(jié)果為:

set()



Python3 列表 Python 集合


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號