python集合的使用
集合是一个无序 不重复的元素序列
s1={10,20,30,40,50}
集合的删操作
products = {'萝卜','白菜' , '水蜜桃'}
products.remove('白菜')
集合的查操作
s2 = {'刘帅' , '英标','高源'}
if '刘帅' in s2:
print("刘帅在s1集合中")
print(products)
1. 获取所有同学的信息集合
students = {'赵飞', '李航', '封勇', '张天宇'}
2. 获取所有已提交同学信息集合
submitted = {'赵飞', '李航'}
3. 求差集
print(students - submitted) # 没有交作业的同学
本文由mdnice多平台发布

浙公网安备 33010602011771号