Python 集合方法
從 fruits 集合刪除所有元素:
fruits = {"apple", "banana", "cherry"} fruits.clear() print(fruits)
運行實例
clear() 方法刪除集合中的所有元素。
set.clear()
無參數。