Python中如何创建集合 Python中的集合是一种无序且不重复的数据类型。在创建集合时,我们可以使用set()函数,直接将一组数据作为参数传递给它。 使用set()函数创建集合 以下是使用set()函数创建集合的方式: # 创建一个空集合 empty_set = set() print(empty_set) # 创建一个包含元素的集合 number_set = set([1,2,3,4,5]) print(number_set) # 创建一个字符串集合 string_set = set("Hello, Python!")