gzj137070928 发表于 2020-10-21 13:15:55

set的回顾

set集合具有唯一性,无序性,所以没有索引index
frozenset()用来限制集合的修改
set1 = frozenset()
set2 = {1, 3, 2, 5}
print(set1 == set2)
# 下面则不可创建集合
try:
    set3 = {}
except Exception as e:
    print(e)
try:
    set1.add(4)# set1不可变更
except Exception as e1:
    print(e1)
set2.add(8)
set2.remove(3)
print(set2)
set4 = {1, 1.0}
print(set4)
页: [1]
查看完整版本: set的回顾