Python Set clear()方法 分类:Python 3 教程 发布时间:2026-01-14 更新时间:2026-01-14 父文章:Python3 集合目录描述语法参数返回值实例描述 clear() 方法用于移除集合中的所有元素。 语法 clear()方法语法: set.clear() 参数 无。 返回值 无。 实例 移除 fruits 集合中的所有元素: fruits = {"apple", "banana", "cherry"} fruits.clear() print(fruits) 输出结果为: set() 上一篇:Python Set add(...下一篇:Python Set copy...