Python Set clear()方法2025-07-14 17:07•Python•阅读 Python 集合描述clear() 方法用于移除集合中的所有元素。语法clear()方法语法: set.clear() 参数无。返回值无。实例移除 fruits 集合中的所有元素:实例 1fruits = {"apple", "banana", "cherry"} fruits.clear()print(fruits)输出结果为: set() Python 集合